Skip to content

Commit

Permalink
fix(constants): extract from config
Browse files Browse the repository at this point in the history
  • Loading branch information
dargmuesli committed Aug 23, 2022
1 parent 123bf46 commit dc1c093
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion nuxt/components/_/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ import { LocaleObject } from '@nuxtjs/i18n/types'
import { defineComponent } from '#app'
import { LOCALES } from '~~/nuxt.config'
import { LOCALES } from '~/plugins/util/constants'
export default defineComponent({
name: 'MaevsiFooter',
Expand Down
29 changes: 9 additions & 20 deletions nuxt/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
import { defineNuxtConfig } from '@nuxt/bridge'
import { LocaleObject } from '@nuxtjs/i18n/types'
import { Configuration } from 'webpack'

import localeDe from './locales/de.json'
import localeEn from './locales/en.json'
import { BASE_URL } from './plugins/util/constants'
import {
BASE_URL,
SITEMAP_EXCLUSIONS,
SITEMAP_EXCLUSIONS_LOCALIZED,
LOCALES,
} from './plugins/util/constants'

export const LOCALES: LocaleObject[] = [
{
code: 'en',
name: 'English',
iso: 'en', // Will be used as catchall locale by default.
},
{
code: 'de',
name: 'Deutsch',
iso: 'de',
},
]
const EXCLUSIONS = ['/%F0%9F%AB%96']
const EXCLUSIONS_LOCALIZED = []

for (const exclusion of EXCLUSIONS) {
for (const exclusion of SITEMAP_EXCLUSIONS) {
for (const locale of LOCALES) {
EXCLUSIONS_LOCALIZED.push(`/${locale.code}${exclusion}`)
SITEMAP_EXCLUSIONS_LOCALIZED.push(`/${locale.code}${exclusion}`)
}
}

Expand Down Expand Up @@ -210,7 +199,7 @@ export default defineNuxtConfig({
Sitemap: BASE_URL + '/sitemap.xml',
},
],
['@nuxtjs/sitemap', { exclude: EXCLUSIONS_LOCALIZED, i18n: true }], // Should be declared at the end of the array.
['@nuxtjs/sitemap', { exclude: SITEMAP_EXCLUSIONS_LOCALIZED, i18n: true }], // Should be declared at the end of the array.
],
nitro: {
autoImport: {
Expand Down
17 changes: 17 additions & 0 deletions nuxt/plugins/util/constants.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
import { LocaleObject } from '@nuxtjs/i18n/types'

export const STACK_DOMAIN =
process.env.NUXT_ENV_STACK_DOMAIN || 'localhost:3000'
export const BASE_URL =
(process.env.NUXT_ENV_STACK_DOMAIN === undefined ? 'http' : 'https') +
'://' +
STACK_DOMAIN

export const LOCALES: LocaleObject[] = [
{
code: 'en',
name: 'English',
iso: 'en', // Will be used as catchall locale by default.
},
{
code: 'de',
name: 'Deutsch',
iso: 'de',
},
]
export const SITEMAP_EXCLUSIONS = ['/%F0%9F%AB%96']
export const SITEMAP_EXCLUSIONS_LOCALIZED: string[] = []

export const ITEMS_PER_PAGE = 8
export const ITEMS_PER_PAGE_LARGE = 100
export const JWT_NAME = '__Secure-jwt'

0 comments on commit dc1c093

Please sign in to comment.