mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
parent
14fe6792ae
commit
5a8e6e4bdf
@ -111,8 +111,8 @@ export async function getRouteData(route) {
|
||||
// Send back a copy of route with meta based on Component definition
|
||||
return {
|
||||
...route,
|
||||
meta: getMatchedComponents(route).map((Component) => {
|
||||
return Component.options.meta || route.meta || {}
|
||||
meta: getMatchedComponents(route).map((Component, index) => {
|
||||
return { ...Component.options.meta, ...(index ? {} : route.meta) }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
3
test/fixtures/with-config/nuxt.config.js
vendored
3
test/fixtures/with-config/nuxt.config.js
vendored
@ -17,7 +17,8 @@ export default {
|
||||
{
|
||||
name: 'about-bis',
|
||||
path: '/about-bis',
|
||||
component: '~/pages/about.vue'
|
||||
component: '~/pages/about.vue',
|
||||
meta: { text: 'test-meta' }
|
||||
},
|
||||
{
|
||||
path: '/redirect/about-bis',
|
||||
|
6
test/fixtures/with-config/pages/about.vue
vendored
6
test/fixtures/with-config/pages/about.vue
vendored
@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>About page</h1>
|
||||
<h2>{{ meta[0].text }}</h2>
|
||||
<NuxtLink to="/">
|
||||
Home page
|
||||
</NuxtLink>
|
||||
@ -9,6 +10,9 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
layout: 'custom'
|
||||
layout: 'custom',
|
||||
asyncData({ route }) {
|
||||
return { meta: route.meta || 'empty-meta' }
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -134,6 +134,7 @@ describe('with-config', () => {
|
||||
const html = window.document.body.innerHTML
|
||||
expect(html).toContain('<h1>Custom layout</h1>')
|
||||
expect(html).toContain('<h1>About page</h1>')
|
||||
expect(html).toContain('<h2>test-meta</h2>')
|
||||
})
|
||||
|
||||
test('/test/not-existed should return 404', async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user