Skip to content

Commit

Permalink
[TECH] Simplifier la lecture des configurations i18n en fonction du d…
Browse files Browse the repository at this point in the history
…omaine.
  • Loading branch information
pix-service-auto-merge authored Dec 19, 2022
2 parents 139a6a8 + 8768ea8 commit 0a9baff
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const config = {
siteDomain: process.env.SITE_DOMAIN,
isFrenchDomain: process.env.SITE_DOMAIN === 'pix.fr',
isPixSite: process.env.SITE === SITES_PRISMIC_TAGS.PIX_SITE,
isSeoIndexingEnabled: process.env.SEO_ENABLE_INDEXING === 'true',
prismic: {
apiEndpoint: process.env.PRISMIC_API_ENDPOINT,
},
Expand Down
29 changes: 21 additions & 8 deletions nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
import { transports } from 'winston'
import routes from './services/get-routes-to-generate'
import isSeoIndexingEnabled from './services/is-seo-indexing-enabled'
import { language } from './config/language'
import { config } from './config/environment'
import { SITES_PRISMIC_TAGS } from './services/available-sites'

const i18nConfigurationForFrenchDomain = {
defaultLocale: 'fr-fr',
strategy: 'prefix_except_default',
vueI18n: {
fallbackLocale: 'fr-fr',
},
}

const i18nConfigurationForInternationalDomain = {
defaultLocale: 'fr',
strategy: 'prefix',
vueI18n: {
fallbackLocale: 'fr',
},
}

const nuxtConfig = {
generate: {
routes,
Expand Down Expand Up @@ -43,7 +58,7 @@ const nuxtConfig = {
content:
'Pix est le service public en ligne pour évaluer, développer et certifier ses compétences numériques tout au long de la vie.',
},
isSeoIndexingEnabled() ? {} : { name: 'robots', content: 'noindex' },
config.isSeoIndexingEnabled ? {} : { name: 'robots', content: 'noindex' },
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
script: [],
Expand Down Expand Up @@ -85,14 +100,12 @@ const nuxtConfig = {

i18n: {
detectBrowserLanguage: false,
defaultLocale: config.isFrenchDomain ? 'fr-fr' : 'fr',
strategy: config.isFrenchDomain ? 'prefix_except_default' : 'prefix',
locales: language.locales,
lazy: true,
langDir: 'lang/',
vueI18n: {
fallbackLocale: config.isFrenchDomain ? 'fr-fr' : 'fr',
},
...(config.isFrenchDomain
? i18nConfigurationForFrenchDomain
: i18nConfigurationForInternationalDomain),
},

prismic: {
Expand Down Expand Up @@ -133,7 +146,7 @@ const nuxtConfig = {
robots: () => {
return {
UserAgent: '*',
Disallow: isSeoIndexingEnabled() ? '' : '/',
Disallow: config.isSeoIndexingEnabled ? '' : '/',
}
},

Expand Down
3 changes: 0 additions & 3 deletions services/is-seo-indexing-enabled.js

This file was deleted.

0 comments on commit 0a9baff

Please sign in to comment.