first commit
This commit is contained in:
25
components/MsgContent.vue
Normal file
25
components/MsgContent.vue
Normal file
@@ -0,0 +1,25 @@
|
||||
<script setup>
|
||||
import { marked } from "marked"
|
||||
import hljs from "highlight.js"
|
||||
|
||||
marked.setOptions({
|
||||
highlight: function (code, lang) {
|
||||
const language = hljs.getLanguage(lang) ? lang : 'plaintext'
|
||||
return hljs.highlight(code, { language }).value
|
||||
},
|
||||
langPrefix: 'hljs language-', // highlight.js css class prefix
|
||||
})
|
||||
|
||||
const props = defineProps(['content'])
|
||||
const contentHtml = computed(() => {
|
||||
return props.content ? marked(props.content) : ''
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-html="contentHtml"
|
||||
></div>
|
||||
|
||||
</template>
|
||||
Reference in New Issue
Block a user