mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-22 03:12:41 +00:00
docs: update nuxt/content example
This commit is contained in:
parent
8c900bc9d0
commit
a33bb94688
@ -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>
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user