diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-01-19 14:45:06 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-01-19 14:47:40 +0100 |
| commit | 1fa8d8281371db25ef9382b6087b7f3c0db73fe3 (patch) | |
| tree | 898aee1e9a23c06e9658de240474d90870190e68 /src | |
| parent | a26b775b7bbf1abd3e99c8bf9ce4c7522d3a0adc (diff) | |
refactor(config): move defaultLocale as property of config.locales
I will need the country code, so I think it makes more sense to gather
them inside the same property.
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/Layouts/Layout.tsx | 2 | ||||
| -rw-r--r-- | src/components/PostPreview/PostPreview.tsx | 2 | ||||
| -rw-r--r-- | src/config/website.ts | 5 | ||||
| -rw-r--r-- | src/pages/article/[slug].tsx | 4 | ||||
| -rw-r--r-- | src/pages/blog/index.tsx | 4 | ||||
| -rw-r--r-- | src/pages/contact.tsx | 2 | ||||
| -rw-r--r-- | src/pages/cv.tsx | 2 | ||||
| -rw-r--r-- | src/pages/index.tsx | 2 | ||||
| -rw-r--r-- | src/pages/mentions-legales.tsx | 4 | ||||
| -rw-r--r-- | src/pages/sujet/[slug].tsx | 4 | ||||
| -rw-r--r-- | src/pages/thematique/[slug].tsx | 4 | ||||
| -rw-r--r-- | src/utils/helpers/i18n.ts | 3 | ||||
| -rw-r--r-- | src/utils/helpers/rss.ts | 2 |
13 files changed, 22 insertions, 18 deletions
diff --git a/src/components/Layouts/Layout.tsx b/src/components/Layouts/Layout.tsx index 2e7d255..1ca954a 100644 --- a/src/components/Layouts/Layout.tsx +++ b/src/components/Layouts/Layout.tsx @@ -34,7 +34,7 @@ const Layout = ({ copyrightYear: Number(config.copyright.startYear), creator: { '@id': `${config.url}/#branding` }, editor: { '@id': `${config.url}/#branding` }, - inLanguage: config.defaultLocale, + inLanguage: config.locales.defaultLocale, potentialAction: { '@type': 'SearchAction', target: `${config.url}/recherche?s={query}`, diff --git a/src/components/PostPreview/PostPreview.tsx b/src/components/PostPreview/PostPreview.tsx index 2a0bcf1..47dbe5e 100644 --- a/src/components/PostPreview/PostPreview.tsx +++ b/src/components/PostPreview/PostPreview.tsx @@ -45,7 +45,7 @@ const PostPreview = ({ datePublished: publicationDate.toISOString(), editor: { '@id': `${config.url}/#branding` }, image: post.featuredImage?.sourceUrl, - inLanguage: config.defaultLocale, + inLanguage: config.locales.defaultLocale, isBasedOn: `${config.url}/article/${post.slug}`, isPartOf: { '@id': `${config.url}/blog` }, license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr', diff --git a/src/config/website.ts b/src/config/website.ts index d8721c5..12645a7 100644 --- a/src/config/website.ts +++ b/src/config/website.ts @@ -7,7 +7,10 @@ export const config = { startYear: '2012', endYear: new Date().getFullYear(), }, - defaultLocale: 'fr', + locales: { + defaultLocale: 'fr', + defaultCountry: 'FR', + }, postsPerPage: 10, url: process.env.NEXT_PUBLIC_FRONTEND_URL, }; diff --git a/src/pages/article/[slug].tsx b/src/pages/article/[slug].tsx index 8c345b7..70a12dc 100644 --- a/src/pages/article/[slug].tsx +++ b/src/pages/article/[slug].tsx @@ -43,7 +43,7 @@ const SingleArticle: NextPageWithLayout<ArticleProps> = ({ post }) => { }; const router = useRouter(); - const locale = router.locale ? router.locale : config.defaultLocale; + const locale = router.locale ? router.locale : config.locales.defaultLocale; useEffect(() => { addPrismClasses(); @@ -97,7 +97,7 @@ const SingleArticle: NextPageWithLayout<ArticleProps> = ({ post }) => { discussionUrl: `${config.url}${router.asPath}/#comments`, editor: { '@id': `${config.url}/#branding` }, image: featuredImage?.sourceUrl, - inLanguage: config.defaultLocale, + inLanguage: config.locales.defaultLocale, isPartOf: { '@id': `${config.url}/blog`, }, diff --git a/src/pages/blog/index.tsx b/src/pages/blog/index.tsx index 765a93b..bb16d37 100644 --- a/src/pages/blog/index.tsx +++ b/src/pages/blog/index.tsx @@ -68,7 +68,7 @@ const Blog: NextPageWithLayout<BlogPageProps> = ({ fallback }) => { breadcrumb: { '@id': `${config.url}/#breadcrumb` }, name: seo.blog.title, description: seo.blog.description, - inLanguage: config.defaultLocale, + inLanguage: config.locales.defaultLocale, reviewedBy: { '@id': `${config.url}/#branding` }, url: `${config.url}`, isPartOf: { @@ -82,7 +82,7 @@ const Blog: NextPageWithLayout<BlogPageProps> = ({ fallback }) => { author: { '@id': `${config.url}/#branding` }, creator: { '@id': `${config.url}/#branding` }, editor: { '@id': `${config.url}/#branding` }, - inLanguage: config.defaultLocale, + inLanguage: config.locales.defaultLocale, license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr', mainEntityOfPage: { '@id': `${config.url}${router.asPath}` }, }; diff --git a/src/pages/contact.tsx b/src/pages/contact.tsx index ba462c0..659da8a 100644 --- a/src/pages/contact.tsx +++ b/src/pages/contact.tsx @@ -80,7 +80,7 @@ const ContactPage: NextPageWithLayout = () => { author: { '@id': `${config.url}/#branding` }, creator: { '@id': `${config.url}/#branding` }, editor: { '@id': `${config.url}/#branding` }, - inLanguage: config.defaultLocale, + inLanguage: config.locales.defaultLocale, license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr', mainEntityOfPage: { '@id': `${config.url}${router.asPath}` }, }; diff --git a/src/pages/cv.tsx b/src/pages/cv.tsx index 78e9a6e..ac5841e 100644 --- a/src/pages/cv.tsx +++ b/src/pages/cv.tsx @@ -54,7 +54,7 @@ const CV: NextPageWithLayout = () => { datePublished: publicationDate.toISOString(), editor: { '@id': `${config.url}/#branding` }, image, - inLanguage: config.defaultLocale, + inLanguage: config.locales.defaultLocale, license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr', thumbnailUrl: image, mainEntityOfPage: { '@id': `${config.url}${router.asPath}` }, diff --git a/src/pages/index.tsx b/src/pages/index.tsx index f59602f..32f1373 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -101,7 +101,7 @@ const Home: NextPageWithLayout = () => { author: { '@id': `${config.url}/#branding` }, creator: { '@id': `${config.url}/#branding` }, editor: { '@id': `${config.url}/#branding` }, - inLanguage: config.defaultLocale, + inLanguage: config.locales.defaultLocale, license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr', reviewedBy: { '@id': `${config.url}/#branding` }, url: `${config.url}`, diff --git a/src/pages/mentions-legales.tsx b/src/pages/mentions-legales.tsx index 81d8e98..e7da49a 100644 --- a/src/pages/mentions-legales.tsx +++ b/src/pages/mentions-legales.tsx @@ -38,7 +38,7 @@ const LegalNotice: NextPageWithLayout = () => { breadcrumb: { '@id': `${config.url}/#breadcrumb` }, name: seo.legalNotice.title, description: seo.legalNotice.description, - inLanguage: config.defaultLocale, + inLanguage: config.locales.defaultLocale, license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr', reviewedBy: { '@id': `${config.url}/#branding` }, url: `${config.url}${router.asPath}`, @@ -59,7 +59,7 @@ const LegalNotice: NextPageWithLayout = () => { dateModified: updateDate.toISOString(), datePublished: publicationDate.toISOString(), editor: { '@id': `${config.url}/#branding` }, - inLanguage: config.defaultLocale, + inLanguage: config.locales.defaultLocale, license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr', mainEntityOfPage: { '@id': `${config.url}${router.asPath}` }, }; diff --git a/src/pages/sujet/[slug].tsx b/src/pages/sujet/[slug].tsx index 97c76c0..bc87845 100644 --- a/src/pages/sujet/[slug].tsx +++ b/src/pages/sujet/[slug].tsx @@ -59,7 +59,7 @@ const Subject: NextPageWithLayout<SubjectProps> = ({ subject }) => { breadcrumb: { '@id': `${config.url}/#breadcrumb` }, name: subject.seo.title, description: subject.seo.metaDesc, - inLanguage: config.defaultLocale, + inLanguage: config.locales.defaultLocale, reviewedBy: { '@id': `${config.url}/#branding` }, url: `${config.url}`, isPartOf: { @@ -84,7 +84,7 @@ const Subject: NextPageWithLayout<SubjectProps> = ({ subject }) => { editor: { '@id': `${config.url}/#branding` }, thumbnailUrl: subject.featuredImage?.sourceUrl, image: subject.featuredImage?.sourceUrl, - inLanguage: config.defaultLocale, + inLanguage: config.locales.defaultLocale, isPartOf: { '@id': `${config.url}/blog` }, license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr', mainEntityOfPage: { '@id': `${config.url}${router.asPath}` }, diff --git a/src/pages/thematique/[slug].tsx b/src/pages/thematique/[slug].tsx index 660a207..1964146 100644 --- a/src/pages/thematique/[slug].tsx +++ b/src/pages/thematique/[slug].tsx @@ -58,7 +58,7 @@ const Thematic: NextPageWithLayout<ThematicProps> = ({ thematic }) => { breadcrumb: { '@id': `${config.url}/#breadcrumb` }, name: thematic.seo.title, description: thematic.seo.metaDesc, - inLanguage: config.defaultLocale, + inLanguage: config.locales.defaultLocale, reviewedBy: { '@id': `${config.url}/#branding` }, url: `${config.url}`, }; @@ -78,7 +78,7 @@ const Thematic: NextPageWithLayout<ThematicProps> = ({ thematic }) => { dateModified: updateDate.toISOString(), datePublished: publicationDate.toISOString(), editor: { '@id': `${config.url}/#branding` }, - inLanguage: config.defaultLocale, + inLanguage: config.locales.defaultLocale, isPartOf: { '@id': `${config.url}/blog` }, license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr', mainEntityOfPage: { '@id': `${config.url}${router.asPath}` }, diff --git a/src/utils/helpers/i18n.ts b/src/utils/helpers/i18n.ts index 38616a2..18f966a 100644 --- a/src/utils/helpers/i18n.ts +++ b/src/utils/helpers/i18n.ts @@ -1,3 +1,4 @@ +import { config } from '@config/website'; import type { I18n } from '@lingui/core'; import { en, fr } from 'make-plural/plurals'; @@ -11,7 +12,7 @@ export const locales = { fr: 'Français', }; -export const defaultLocale = 'fr'; +export const defaultLocale = config.locales.defaultLocale; export function initTranslation(i18n: I18n): void { i18n.loadLocaleData({ diff --git a/src/utils/helpers/rss.ts b/src/utils/helpers/rss.ts index 7851ff8..7806f7c 100644 --- a/src/utils/helpers/rss.ts +++ b/src/utils/helpers/rss.ts @@ -39,7 +39,7 @@ export const generateFeed = async () => { }, generator: 'Feed & NextJS', id: websiteUrl, - language: config.defaultLocale, + language: config.locales.defaultLocale, link: websiteUrl, title, }); |
