2018-01-24 07:39:21 +00:00
|
|
|
<template>
|
2018-01-25 08:29:23 +00:00
|
|
|
<div v-html="marked(text)" class="markdown" />
|
2018-01-24 07:39:21 +00:00
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import marked from 'marked'
|
|
|
|
marked.setOptions({
|
|
|
|
renderer: new marked.Renderer(),
|
|
|
|
gfm: true,
|
|
|
|
tables: true,
|
|
|
|
breaks: true,
|
|
|
|
pedantic: true,
|
|
|
|
sanitize: true,
|
|
|
|
smartLists: true,
|
|
|
|
smartypants: true,
|
|
|
|
})
|
|
|
|
export default {
|
|
|
|
name: 'md',
|
|
|
|
props: {
|
2018-01-25 08:29:23 +00:00
|
|
|
cn: String,
|
|
|
|
us: String,
|
2018-01-24 07:39:21 +00:00
|
|
|
},
|
|
|
|
data () {
|
|
|
|
const { lang } = this.$route.params
|
|
|
|
let text = ''
|
2018-01-25 08:29:23 +00:00
|
|
|
const { cn, us } = this
|
2018-01-24 07:39:21 +00:00
|
|
|
if (this.$slots.default && this.$slots.default[0] && this.$slots.default[0].text) {
|
|
|
|
text = this.$slots.default[0].text
|
|
|
|
} else {
|
2018-01-25 08:29:23 +00:00
|
|
|
text = lang === 'cn' ? cn : us
|
2018-01-24 07:39:21 +00:00
|
|
|
}
|
|
|
|
text = text || ''
|
|
|
|
text = text.split('\n').map(t => t.trim()).join('\n')
|
|
|
|
return {
|
|
|
|
marked,
|
|
|
|
text,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|