-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Document that vue-router does not handle head/metadata like page title #1539
Comments
This topic is useful but we don't really have a place for it. Do you have a suggestion? A PR here would be more helpful. Note that documentation should point the user how to do things, not tell the user what isn't possible |
@posva I was planning to do a PR sometime this week. This is just here as a reminder. I figured a "page head and title" page under the Advanced topics in the guides might be a good place. |
A whole new page for it looks like too much unless there is that much to say. Right now, this could be just mentioned in the afterEach hooks section |
I was planning on including links and examples to a few libraries that can update the head/metadata/title. |
@posva and @Soviut Below are the details that can be added in document The router instance has a afterEach hook that gets called after route change. This can be used to set window title as detailed below: // Let's say this is your router instance, with all "Named Routes" // Assign page titles for each of the "named routes" ROUTER_INSTANCE.afterEach((toRoute, fromRoute) => { |
import` { createMemoryHistory, createRouter } from "vue-router"; const routes = [ const router = createRouter({ router.afterEach((toRoute) => { export default router; Instead of creating a separate PAGE_TITLE object, I think we can embed the title inside the meta tag. |
What problem does this feature solve?
A colleague who is new to Vue expected that vue-router would be able to update the page title; this makes some sense. Vue-router introduces the concept of pages, so there could be an expectation that it also has facilities for updating the page metadata.
It would be good to document that vue-router does not have these facilities, but also link to something like
@vueuse/head
that can.What does the proposed API look like?
A new page in the documentation guides that explains that vue-router does not handle metadata, but gives examples and links to some populate head/metadata libraries like
@vueuse/head
.The text was updated successfully, but these errors were encountered: