NuxtN
Nuxt15mo ago
4 replies
FoxCode

Can I use useContent() and ContentRendererMarkdown?

Hi, I'm using nuxt-content to generate articles, but in some articles, I wanted to fetch a value from another article. Everything works correctly except for generating the ToC
useContent()
ignores everything that is fetched from
useAsyncData
. How can I change this/delay the ToC generation until
useAsyncData
has completed (because I think that's where the problem lies)?

GetCustom.vue:
<template>
    <div class="w-full">
        <ContentRendererMarkdown :value="data">
            <template #empty>
                <p>No content found.</p>
            </template>
        </ContentRendererMarkdown>
        <ContentSlot unwrap="p" />
    </div>
</template>
<script setup>
const props = defineProps({
    url: String
})
const { data } = await useAsyncData('article', () => queryContent('/external-markdown-files/' + props.url).findOne())
</script>


MainArticle.md:
:GetCustom{url="article1"}

## Some heading


/external-markdown-files/article1.md:
## Heading 1
test
## Heading 2


ToC from
const { toc } = useContent()
only includes headings from
MainArticle.md
(## Some heading)
image.png
Was this page helpful?