The fastest way to query and display your content.
The <ContentDoc>
{lang=html} component fetches and renders a single document.
An explicit path can be passed to the component with the path
{lang=ts} prop. If not provided, the $route.path
{lang=ts} will be used.
It uses <ContentRenderer>
{lang=html} and <ContentQuery>
{lang=html} under the hood.
tag
{lang=ts}: The tag to use for the renderer element (if no default slot is provided).- Type:
string
{lang=ts} - Default:
'div'
{lang=ts}
- Type:
path
{lang=ts}: The path of the content to load from content source.- Type:
string
{lang=ts} - Default:
$route.path
{lang=ts}
- Type:
excerpt
{lang=ts}: Whether or not to render the excerpt.- Type:
boolean
{lang=ts} - Default:
false
{lang=ts}
- Type:
query
{lang=ts}: A query to be passed toqueryContent()
.- Type:
QueryBuilderParams
{lang=ts} - Default:
undefined
{lang=ts}
- Type:
head
{lang=ts}: Toggles the usage ofuseContentHead
.- Type:
boolean
{lang=ts} - Default:
true
{lang=ts}
- Type:
The default
{lang=ts} slot can be used to render the content via v-slot="{ data }"
{lang=vue} syntax:
<template>
<main>
<ContentDoc v-slot="{ doc }">
<article>
<h1>{{ doc.title }}</h1>
<ContentRenderer :value="doc" />
</article>
</ContentDoc>
</main>
</template>
The not-found
{lang=ts} slot can be used when no document is found:
<template>
<main>
<ContentDoc>
<template #not-found>
<h1>Document not found</h1>
</template>
</ContentDoc>
</main>
</template>
The empty
{lang=ts} slot can be used to display a default content before rendering the document.
<template>
<main>
<ContentDoc>
<template #empty>
<h1>Document is empty</h1>
</template>
</ContentDoc>
</main>
</template>
<template>
<main>
<!-- Similar to <ContentDoc :path="$route.path" /> -->
<ContentDoc />
</main>
</template>
<template>
<main>
<ContentDoc path="/about" />
</main>
</template>