Skip to content

Expose the head SEO function to be used in layouts#154

Merged
TheAlexLichter merged 8 commits intonuxt-modules:masterfrom
adrienbaron:perf/expose-seo-head-function
Nov 15, 2018
Merged

Expose the head SEO function to be used in layouts#154
TheAlexLichter merged 8 commits intonuxt-modules:masterfrom
adrienbaron:perf/expose-seo-head-function

Conversation

@adrienbaron
Copy link
Copy Markdown

@adrienbaron adrienbaron commented Nov 7, 2018

This PR exposes the SEO head hook function as this.$nuxtI18nSeo on components.

This allows to disable seo head mixin on all components (by setting seo: false in nuxt i18n options).
Then it's possible to do this in your app layout (or wherever):

    head () {
      return this.$nuxtI18nSeo()
    },

This greatly improves performance as SEO links are not recomputed for every components but only for the layout itself.

This changes is not breaking as the default global registration with the same behaviour remains if seo: true in the configuration.

Resolves: #144

@paulgv
Copy link
Copy Markdown
Collaborator

paulgv commented Nov 8, 2018

Thanks @adrienbaron !
Could you also update the documentation to explain how to use the nuxtI18nSeo() method?

@adrienbaron
Copy link
Copy Markdown
Author

@paulgv Done!
Btw thanks a lot to @manniL for his help on this, forgot to mention, and couldn't have done it without his help 👍

@TheAlexLichter
Copy link
Copy Markdown
Contributor

Happy we found a solution 🙊 (Also one that can be default at the next major version)

Comment thread src/plugins/main.js Outdated
@TheAlexLichter TheAlexLichter merged commit ce373c4 into nuxt-modules:master Nov 15, 2018
@kevinmarrec
Copy link
Copy Markdown

@adrienbaron @manniL Last commit on master seems to be related to this PR, and tests are not passing anymore, any ideas ? (CircleCI build fails)

@TheAlexLichter
Copy link
Copy Markdown
Contributor

@kevinmarrec Should be just the vue-ssr id(4eb03412:0). Will fix

@TheAlexLichter
Copy link
Copy Markdown
Contributor

@kevinmarrec fixed

Copy link
Copy Markdown

@harmnot harmnot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why $nuxtI18nSeo is not a function ??

@TheAlexLichter
Copy link
Copy Markdown
Contributor

@harmnot There hasn't been a release yet

@harmnot
Copy link
Copy Markdown

harmnot commented Dec 5, 2018

I was asking this https://cmty.app/nuxt/nuxt-i18n/issues/c176

@harmnot
Copy link
Copy Markdown

harmnot commented Dec 5, 2018

then, I try to find out, and follow the instruction https://github.com/nuxt-community/nuxt-i18n/blob/master/docs/seo.md here and after that , show the $nuxtI18nSeo is not a function

@paulgv
Copy link
Copy Markdown
Collaborator

paulgv commented Jan 24, 2019

Sorry for the delay, this wasn't released until recently in version 5.5.0: https://github.com/nuxt-community/nuxt-i18n/blob/master/CHANGELOG.md#550-2019-01-14

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

Successfully merging this pull request may close these issues.

5 participants