The <ContentRenderer> component renders a document coming from a query with queryContent().

It will use <ContentRendererMarkdown> component to render .md file types.

Other types will currently be passed to default slot via v-slot="{ data }" or be rendered inside <pre /> tag.

Props

  • value: The document to render.
    • Type: ParsedContent
    • Default: {}
  • tag: The tag to use for the renderer element if it is used.
    • Type: string
    • Default: 'div'
  • excerpt: Whether to render the excerpt only without the rest of the content.
    • Type: boolean
    • Default: false
  • components: The map of custom components to use for rendering. This prop will pass to markdown renderer and will not affect other file types.
    • Type: object
    • Default: {}
  • data: A map of variables to inject into the markdown content for later use in binding variables.
    • Type: object
    • Default: {}

Slots

The default slot can be used to render the content via v-slot="{ data }" syntax.

<script setup lang="ts">
const { data } = await useAsyncData('page-data', () => queryContent('/hello').findOne())
</script>

<template>
  <main>
    <ContentRenderer :value="data">
      <h1>{{ data.title }}</h1>
      <ContentRendererMarkdown :value="data" />
    </ContentRenderer>
  </main>
</template>

The empty slot can be used to display a default content when the document is empty:

<script setup lang="ts">
const { data } = await useAsyncData('page-data', () => queryContent('/hello').findOne())
</script>

<template>
  <main>
    <ContentRenderer :value="data">
      <template #empty>
        <p>No content found.</p>
      </template>
    </ContentRenderer>
  </main>
</template>

Surround

[
  {
    "title": "<ContentDoc>",
    "path": "/content-v2/components/content-doc",
    "stem": "content-v2/4.components/1.content-doc",
    "description": "The fastest way to query and display your content."
  },
  {
    "title": "<ContentList>",
    "path": "/content-v2/components/content-list",
    "stem": "content-v2/4.components/3.content-list",
    "description": "The fastest way to query your content with a component."
  }
]