Skip to content
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

How to control variables in index.html on a component basis? #100

Open
spazer5 opened this issue May 12, 2019 · 2 comments
Open

How to control variables in index.html on a component basis? #100

spazer5 opened this issue May 12, 2019 · 2 comments

Comments

@spazer5
Copy link

spazer5 commented May 12, 2019

I'd like to control meta title, description, and other things. but on a component basis since they differ on each route.

For example, a single post can have unique meta description and title (i'm using serverPrefetch).

How would i do this?

Also how would I perform a redirect post "serverPrefetch" in case a record doesn't exist.

@zickat
Copy link
Contributor

zickat commented May 13, 2019

To do with, i'm using vue-meta package

In my index.html:

<head>
   {{{ meta.inject().title.text() }}}
    {{{ meta.inject().meta.text() }}}
    {{{ meta.inject().link.text() }}}
    {{{ renderResourceHints() }}}
    {{{ renderStyles() }}}
</head>

In my entry-server, I fetch meta/title to be sure it's prefetch, and then I bind the meta variable to the context (in entry-server) :

context.meta = app.$meta();

On client side, I use a mixin to refresh title/meta when the user navigate (and vue-meta change meta/title inside the dom)

Hope this can help you 😃

@spazer5
Copy link
Author

spazer5 commented May 17, 2019

Thank you so much Zickat!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants