mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 21:55:11 +00:00
docs: example using useMeta
with definePageMeta
(#3552)
This commit is contained in:
parent
0f2cba5b1d
commit
cbb2e9ce2b
@ -58,3 +58,29 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Example: usage with definePageMeta
|
||||||
|
|
||||||
|
You can use `definePageMeta` along with `useMeta` to set metadata based on the current route.
|
||||||
|
|
||||||
|
For example, to include the page title alongside your app name, first define your page title:
|
||||||
|
|
||||||
|
```vue{}[pages/some-page.vue]
|
||||||
|
<script setup>
|
||||||
|
definePageMeta({
|
||||||
|
title: 'Some Page'
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
And then in your layout file:
|
||||||
|
|
||||||
|
```vue{}[layouts/default.vue]
|
||||||
|
<script setup>
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
|
useMeta({
|
||||||
|
title: computed(() => `App Name - ${route.meta.title}`)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user