mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-05 22:07:10 -04:00
22 lines
587 B
Vue
22 lines
587 B
Vue
![]() |
<script setup lang="ts">
|
||
|
import { marked } from 'marked';
|
||
|
import DomPurify from 'dompurify';
|
||
|
|
||
|
const props = withDefaults(defineProps<{ markdown?: string }>(), { markdown: '' });
|
||
|
const { markdown } = toRefs(props);
|
||
|
|
||
|
marked.use({
|
||
|
renderer: {
|
||
|
link(href, title, text) {
|
||
|
return `<a class="text-primary transition decoration-none hover:underline" href="${href}" target="_blank" rel="noopener">${text}</a>`;
|
||
|
},
|
||
|
},
|
||
|
});
|
||
|
|
||
|
const html = computed(() => DomPurify.sanitize(marked(markdown.value), { ADD_ATTR: ['target'] }));
|
||
|
</script>
|
||
|
|
||
|
<template>
|
||
|
<div v-html="html" />
|
||
|
</template>
|