here I am trying to render the HighlightJs component inside splitContent method. But it is not working instead it displays the Component name as a html tag. Also I tried registering it has a global component, still it doesn't work.
<script setup lang="ts">
import HighlightJs from "./components/HighlightJs.vue";
const splitContent: (content: string) => string = (content) => {
const paragraphs = content.split("\n\n");
const codeBlocks = content.split("```");
if (codeBlocks.length > 1) {
return codeBlocks
.map((codeBlock, i) => {
if (i % 2 === 0) {
return `<p>${codeBlock}</p>`;
} else {
return `<HighlightJs code="${codeBlock}"></HighlightJs>`; // component is not rendered
}
})
.join("");
} else {
return paragraphs.map((paragraph) => `<p>${paragraph}</p>`).join("");
}
};
</script>
<template>
<div
class="bg-gray-500 text-white p-4 rounded-lg prose"
v-html="splitContent(content.answer)"
></div>
</template>