Skip to content

Commit

Permalink
docs: update nuxt/content example
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Jan 21, 2025
1 parent 09c3f79 commit 5429876
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions docs/2.guide/2.directory-structure/1.content.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,24 @@ The module automatically loads and parses them.

## Render Content

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:
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:

```vue [pages/[...slug\\].vue]
<script lang="ts" setup>
const route = useRoute()
const { data: page } = await useAsyncData(route.path, () => {
return queryCollection('content').path(route.path).first()
})
</script>
<template>
<main>
<!-- ContentDoc returns content for `$route.path` by default or you can pass a `path` prop -->
<ContentDoc />
</main>
<div>
<header><!-- ... --></header>
<ContentRenderer v-if="page" :value="page" />
<footer><!-- ... --></footer>
</div>
</template>
```

Expand Down

0 comments on commit 5429876

Please sign in to comment.