Components
ContentRenderer
Takes your component from an AST to a wonderful template.
The <ContentRenderer>
component renders a document coming from a query with queryCollections()
.
This component works only with
pages
collections.
Props
value
: The document to render.- Type:
ParsedContent
- Default:
{}
- Type:
tag
: The tag to use for the renderer element if it is used.- Type:
string
- Default:
'div'
- Type:
excerpt
: Whether to render the excerpt only without the rest of the content.- Type:
boolean
- Default:
false
- Type:
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:
{}
- Type:
data
: A map of variables to inject into the markdown content for later use in binding variables.- Type:
object
- Default:
{}
- Type:
prose
: Whether or not to render Prose components instead of HTML tags.- Type:
boolean
- Default:
undefined
- Type:
class
: Root tag to use for rendering.- Type:
string
orobject
- Default:
undefined
- Type:
unwrap
: Tags to unwrap separated by spaces.- Type:
boolean
orstring
- Default:
false
- Example:
'ul li'
- Type:
Example
pages/[...slug].vue
<script lang="ts" setup>
const route = useRoute()
const { data: page } = await useAsyncData(route.path, () => {
return queryCollection('docs').path(route.path).first()
})
</script>
<template>
<ContentRenderer v-if="page" :value="page" />
</template>