From 0eabc48c8c934272052187dcd9d32ba998aa07d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rialland?= Date: Wed, 15 Mar 2023 12:42:15 +0100 Subject: [PATCH] Remove dynamic translation in Meta component --- site/scripts/i18n/parser.config.js | 2 ++ site/source/components/PageData.tsx | 20 +++++++++-- site/source/components/utils/Meta.tsx | 36 +++++-------------- site/source/pages/Accessibilité.tsx | 1 - site/source/pages/Documentation.tsx | 1 - site/source/pages/Plan.tsx | 1 - site/source/pages/_landing/Landing.tsx | 1 - .../choix-statut-juridique/index.tsx | 1 - site/source/pages/budget/index.tsx | 1 - site/source/pages/integration/API.tsx | 1 - site/source/pages/integration/Iframe.tsx | 1 - site/source/pages/integration/Library.tsx | 1 - site/source/pages/integration/Options.tsx | 1 - site/source/pages/integration/Spreadsheet.tsx | 1 - site/source/pages/nouveautés/index.tsx | 1 - .../pages/simulateurs-et-assistants/index.tsx | 1 - site/source/pages/statistiques/LazyStats.tsx | 1 - 17 files changed, 28 insertions(+), 44 deletions(-) diff --git a/site/scripts/i18n/parser.config.js b/site/scripts/i18n/parser.config.js index 8fdcbc410..1368defe9 100644 --- a/site/scripts/i18n/parser.config.js +++ b/site/scripts/i18n/parser.config.js @@ -98,4 +98,6 @@ export default { verbose: false, // Display info about the parsing including some stats + + failOnWarnings: true, } diff --git a/site/source/components/PageData.tsx b/site/source/components/PageData.tsx index 9d4aaed98..838e4566a 100644 --- a/site/source/components/PageData.tsx +++ b/site/source/components/PageData.tsx @@ -10,10 +10,14 @@ import { Emoji } from '@/design-system/emoji' import { Spacing } from '@/design-system/layout' import { H1 } from '@/design-system/typography/heading' import { Intro } from '@/design-system/typography/paragraphs' -import { useCurrentSimulatorData } from '@/hooks/useCurrentSimulatorData' +import { + MergedSimulatorDataValues, + useCurrentSimulatorData, +} from '@/hooks/useCurrentSimulatorData' import { useIsEmbedded } from '@/hooks/useIsEmbedded' import useSimulationConfig from '@/hooks/useSimulationConfig' import { situationSelector } from '@/store/selectors/simulationSelectors' +import { Merge, ToOptional } from '@/types/utils' import { NextSteps } from '../pages/simulateurs/NextSteps' import { TrackChapter } from './ATInternetTracking' @@ -57,9 +61,21 @@ export default function PageData() { ...(typeof tracking === 'string' ? { chapter2: tracking } : tracking), } as ComponentPropsWithoutRef + const { ogTitle, ogDescription, ogImage } = meta as Merge< + MergedSimulatorDataValues['meta'] + > + return ( - {meta && } + {meta && ( + + )} {beta && } {title && !inIframe && ( diff --git a/site/source/components/utils/Meta.tsx b/site/source/components/utils/Meta.tsx index ecae9fb14..ff71d9e5b 100644 --- a/site/source/components/utils/Meta.tsx +++ b/site/source/components/utils/Meta.tsx @@ -1,9 +1,6 @@ -import { useTranslation } from 'react-i18next' - import DefaultHelmet from './DefaultHelmet' type PropType = { - page: string title: string description: string ogDescription?: string @@ -12,44 +9,27 @@ type PropType = { } export default function Meta({ - page, title, description, ogDescription, ogTitle, ogImage, }: PropType) { - const { t } = useTranslation() - - // TODO: refacto des traductions en évitant qu'elles soit dynamique - const meta = { - title, - description: t(`${page}.description`, description) || description, - ogDescription: ogDescription - ? t(`${page}.ogDescription`, ogDescription) || ogDescription - : description, - ogTitle: ogTitle ? t(`${page}.ogTitle`, ogTitle) || ogTitle : title, - ogImage: ogImage ? t(`${page}.ogImage`, ogImage) || ogImage : null, - } - return ( - {meta.title} - + {title} + - - - {meta.ogImage && ( + + + {ogImage && ( )} diff --git a/site/source/pages/Accessibilité.tsx b/site/source/pages/Accessibilité.tsx index 11d2fe671..5be1c9424 100644 --- a/site/source/pages/Accessibilité.tsx +++ b/site/source/pages/Accessibilité.tsx @@ -15,7 +15,6 @@ export default function Accessibilité() {

Accessibilité

Plan du site
diff --git a/site/source/pages/integration/API.tsx b/site/source/pages/integration/API.tsx index b7890d070..d36104903 100644 --- a/site/source/pages/integration/API.tsx +++ b/site/source/pages/integration/API.tsx @@ -21,7 +21,6 @@ export default function API() {
diff --git a/site/source/pages/integration/Iframe.tsx b/site/source/pages/integration/Iframe.tsx index 1d44bd859..8fb093495 100644 --- a/site/source/pages/integration/Iframe.tsx +++ b/site/source/pages/integration/Iframe.tsx @@ -100,7 +100,6 @@ function IntegrationCustomizer() { Personnalisez l'intégration diff --git a/site/source/pages/integration/Library.tsx b/site/source/pages/integration/Library.tsx index 159f12473..00123d5f5 100644 --- a/site/source/pages/integration/Library.tsx +++ b/site/source/pages/integration/Library.tsx @@ -21,7 +21,6 @@ export default function Library() { return (
diff --git a/site/source/pages/integration/Options.tsx b/site/source/pages/integration/Options.tsx index 81e026819..b71a763f6 100644 --- a/site/source/pages/integration/Options.tsx +++ b/site/source/pages/integration/Options.tsx @@ -18,7 +18,6 @@ export default function Options() { return ( <>