Skip to content

Create my custom component to be used in Markdown files (mermaid for learning purposes) #3268

Answered by ochorocho
ochorocho asked this question in Q&A
Discussion options

You must be logged in to vote

🤦 Found a solution.

<script lang="ts" setup>
import {DefaultTheme} from "vitepress/theme";
import {useSlots, computed, ref, onActivated, onMounted} from "vue";
import mermaid from "mermaid";

const data = ref("") // <--- THIS

mermaid.initialize({
  startOnLoad:true
});

const slots = useSlots()
const content = slots.default()[0].children

mermaid.render('id1', <string>content).then((svg) => {
  console.log(svg.svg)
  data.value = svg.svg  // <--- THIS
})

</script>

<template>
  <div v-html="data"></div>  // <--- THIS
</template>

EDIT: for now it's client side only

<ClientOnly>
    <Typo3Mermaid>
          graph LR
          A --- B
          B-->C[fa:fa-ban forbidden]
          B-->D(fa…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ochorocho
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant