-
Notifications
You must be signed in to change notification settings - Fork 918
feat(core): support injecting meta into router #518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| extendsPageData.forEach((item) => | ||
| Object.assign(data, { item, meta: { ...data.meta, ...item.meta } }) | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
I think it's ready for the feature, improvements can make later together with "frontmatter" when having later discussions |
|
Sorry for delay. (Really busy and kind of tired these days 😅 ) I'll pick up this PR soon. |
| const route = useResolveRouteWithRedirect('/') | ||
|
|
||
| console.log(page.value.meta.foo) // 'bar' | ||
| console.log(route.meta.path) // '/' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As meta is already available in the route.meta, is it necessary to put meta in to page data?
I think we can make meta a property of the Page object, and don't need to put it into page data.
What's your opinion? @Mister-Hope
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds ok to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we remove it from page data, we could not use extendsPageData to modify it. I have two proposals:
- Let users to modify it manually in
onInitializedhook:
onInitialized: (app) => app.pages.forEach((page) => {
page.data.foo = 'foo'
page.routeMeta.title = page.title
// ...
})In fact, the extendsPageData hook could also be removed as we have added page.data property, and users can modify it in this way, too. 😅
- Rename
extendsPageDatatoextendsPage:
extendsPage: (page) => {
page.data.foo = 'foo'
page.routeMeta.title = page.title
// ...
}The only difference is that plugins / themes don't need to traverse the app.pages array by themselves.
|
I've replaced Then this PR could be implemented in a different way. |
|
Implemented in 93cdb53 |
No description provided.