Skip to content

Commit 5429876

Browse files
committedJan 21, 2025
docs: update nuxt/content example

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed
 

‎docs/2.guide/2.directory-structure/1.content.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,24 @@ The module automatically loads and parses them.
3636

3737
## Render Content
3838

39-
To render content pages, add a [catch-all route](/docs/guide/directory-structure/pages/#catch-all-route) using the [`<ContentDoc>`](https://content.nuxt.com/components/content-doc) component:
39+
To render content pages, add a [catch-all route](/docs/guide/directory-structure/pages/#catch-all-route) using the [`<ContentRenderer>`](https://content.nuxt.com/docs/components/content-renderer) component:
4040

4141
```vue [pages/[...slug\\].vue]
42+
<script lang="ts" setup>
43+
const route = useRoute()
44+
const { data: page } = await useAsyncData(route.path, () => {
45+
return queryCollection('content').path(route.path).first()
46+
})
47+
</script>
48+
4249
<template>
43-
<main>
44-
<!-- ContentDoc returns content for `$route.path` by default or you can pass a `path` prop -->
45-
<ContentDoc />
46-
</main>
50+
<div>
51+
<header><!-- ... --></header>
52+
53+
<ContentRenderer v-if="page" :value="page" />
54+
55+
<footer><!-- ... --></footer>
56+
</div>
4757
</template>
4858
```
4959

0 commit comments

Comments
 (0)
Please sign in to comment.