Skip to content

Commit

Permalink
fix: Rename in-component options key from i18n to nuxtI18n
Browse files Browse the repository at this point in the history
This change prevents conflicts with vue-i18n features that also rely on an i18n key in components

BREAKING CHANGE: Pages using i18n key need to be updated to use nuxtI18n key instead

#94, #67
  • Loading branch information
paulgv committed Jun 7, 2018
1 parent 24447a4 commit 5ff618d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/helpers/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const extractComponentOptions = (path) => {
Property (node) {
if (node.key.name === COMPONENT_OPTIONS_KEY) {
const data = script.substring(node.start, node.end)
componentOptions = eval(`({${data}})`).i18n // eslint-disable-line
componentOptions = eval(`({${data}})`)[COMPONENT_OPTIONS_KEY] // eslint-disable-line
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const STRATEGIES = {
PREFIX: 'prefix',
PREFIX_EXCEPT_DEFAULT: 'prefix_except_default'
}
export const COMPONENT_OPTIONS_KEY = 'i18n'
export const COMPONENT_OPTIONS_KEY = 'nuxtI18n'
export const DEFAULT_OPTIONS = {
vueI18n: {},
locales: [],
Expand Down
4 changes: 3 additions & 1 deletion src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
LOCALE_CODE_KEY,
LOCALE_ISO_KEY,
LOCALE_DOMAIN_KEY,
LOCALE_FILE_KEY
LOCALE_FILE_KEY,
COMPONENT_OPTIONS_KEY
} from './helpers/constants'
import { makeRoutes } from './helpers/routes'
import {
Expand Down Expand Up @@ -44,6 +45,7 @@ export default function (userOptions) {
LOCALE_ISO_KEY,
LOCALE_DOMAIN_KEY,
LOCALE_FILE_KEY,
COMPONENT_OPTIONS_KEY,
getLocaleCodes,
getLocaleFromRoute,
getForwarded,
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/seo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import Vue from 'vue'

Vue.mixin({
head () {
const COMPONENT_OPTIONS_KEY = '<%= options.COMPONENT_OPTIONS_KEY %>'
if (
!this._hasMetaInfo ||
!this.$i18n ||
!this.$i18n.locales ||
this.$options.i18n === false ||
(this.$options.i18n && this.$options.i18n.seo === false)
this.$options[COMPONENT_OPTIONS_KEY] === false ||
(this.$options[COMPONENT_OPTIONS_KEY] && this.$options[COMPONENT_OPTIONS_KEY].seo === false)
) {
return {};
}
Expand Down

0 comments on commit 5ff618d

Please sign in to comment.