cyber/src/components/mdRenderer.vue

68 lines
1.2 KiB
Vue
Raw Normal View History

2025-02-14 23:14:54 +08:00
<template>
<div v-html="convertedMarkdown" class="markdown-container"></div>
</template>
<script>
import { ref, watchEffect } from 'vue';
import { marked } from 'marked'; // Use named import
export default {
name: 'MarkdownViewer',
props: {
markdownContent: {
type: String,
required: true
}
},
setup(props) {
const convertedMarkdown = ref('');
watchEffect(() => {
convertedMarkdown.value = marked.parse(props.markdownContent); // Use marked.parse()
});
return {
convertedMarkdown
};
}
};
</script>
<style scoped>
.markdown-container {
font-family: Arial, sans-serif;
line-height: 1.6;
}
.markdown-container h1,
.markdown-container h2,
.markdown-container h3 {
color: #333;
}
.markdown-container p {
margin-bottom: 1rem;
}
.markdown-container code {
background-color: #f4f4f4;
padding: 0.2rem 0.5rem;
border-radius: 4px;
}
.markdown-container pre {
background-color: #f4f4f4;
padding: 1rem;
border-radius: 4px;
overflow: auto;
}
.markdown-container hr {
width: 80%;
height: 1px;
background: linear-gradient(to bottom, rgba(217, 217, 217, 0.6), rgba(114, 114, 114, 0.6));
margin: 20px 0;
border-radius: 2px;
}
</style>