vuejs / rfcs

RFCs for substantial changes / feature additions to Vue core
4.87k stars 546 forks source link

Merge `meta` fields from parent to child #144

Closed posva closed 4 years ago

posva commented 4 years ago

Rendered

KaelWD commented 4 years ago

I believe this is what Nuxt does

vue-meta?

kiaking commented 4 years ago

I like this one. It's going to make meta accessing much easier 🙌

One question. Why is nested key removed in "Basic example" section's example, and not in "Detailed design" section's example?

{
  path: '/parent',
  meta: { nested: { requiresAuth: true, isChild: false } },
  children: [
    { path: 'child', meta: { isChild: true }}
  ]
}

// becomes
{ requiresAuth: true, isChild: true }

And

{
  path: '/parent',
  meta: { nested: { a: true } },
  children: [
    { path: 'child', meta: { nested: { b: true }}}
  ]
}

// becomes
{
  nested: {
    b: true
  }
}

Wouldn't the first example become as below?

{
  nested: {
    requiresAuth: true,
    isChild: true
  },
  isChild: false
}

Or, is nested key means something special?

posva commented 4 years ago

Thanks @kiaking That was indeed a mistake. I fixed it

posva commented 4 years ago

This RFC is now in final comments stage. An RFC in final comments stage means that:

The core team has reviewed the feedback and reached consensus about the general direction of the RFC and believe that this RFC is a worthwhile addition to the framework. Final comments stage does not mean the RFC's design details are final - we may still tweak the details as we implement it and discover new technical insights or constraints. It may even be further adjusted based on user feedback after it lands in an alpha/beta release. If no major objections with solid supporting arguments have been presented after a week, the RFC will be merged and become an active RFC.

Rolanddoda commented 4 years ago

The rendered link gives 404

ludohenin commented 4 years ago

I may jump into that one a bit late but in my case merging meta doesn't sound that great. I mainly use the meta to hold the document title and use it to build it as a tree.

'/'                // title = App name
  'settings'       // title = Setting - App name
    'users'        // title = Users - Settings - App name

As merging the meta.title will break this how to then implement such feature.

posva commented 4 years ago

@ludohenin Since you need all values from meta to create your tree, you probably go through the array of matched like it's shown on documentation. That array is kept the same, only the to.meta and from.meta properties are the results of merging parent to child meta properties, the ones at to.matched and from.matched are the originals

ludohenin commented 4 years ago

@posva ah OK, perfect then ;-)