From e4d5b8151802517b2943756fc0d09ffa95e2c4e2 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Sat, 29 Jan 2022 18:21:37 +0100
Subject: chore: replace lingui functions with react-intl

---
 src/pages/mentions-legales.tsx | 35 ++++++++++++++++++++++++++---------
 1 file changed, 26 insertions(+), 9 deletions(-)

(limited to 'src/pages/mentions-legales.tsx')

diff --git a/src/pages/mentions-legales.tsx b/src/pages/mentions-legales.tsx
index e13a7e2..0ec92a2 100644
--- a/src/pages/mentions-legales.tsx
+++ b/src/pages/mentions-legales.tsx
@@ -2,13 +2,11 @@ import { getLayout } from '@components/Layouts/Layout';
 import PostHeader from '@components/PostHeader/PostHeader';
 import Sidebar from '@components/Sidebar/Sidebar';
 import { ToC } from '@components/Widgets';
-import { seo } from '@config/seo';
 import { config } from '@config/website';
 import LegalNoticeContent, {
   intro,
   meta,
 } from '@content/pages/legal-notice.mdx';
-import { t } from '@lingui/macro';
 import styles from '@styles/pages/Page.module.scss';
 import { NextPageWithLayout } from '@ts/types/app';
 import { ArticleMeta } from '@ts/types/articles';
@@ -16,9 +14,11 @@ import { loadTranslation } from '@utils/helpers/i18n';
 import { GetStaticProps, GetStaticPropsContext } from 'next';
 import Head from 'next/head';
 import { useRouter } from 'next/router';
+import { useIntl } from 'react-intl';
 import { Article, Graph, WebPage } from 'schema-dts';
 
 const LegalNotice: NextPageWithLayout = () => {
+  const intl = useIntl();
   const router = useRouter();
   const dates = {
     publication: meta.publishedOn,
@@ -28,8 +28,25 @@ const LegalNotice: NextPageWithLayout = () => {
   const pageMeta: ArticleMeta = {
     dates,
   };
+  const pageTitle = intl.formatMessage(
+    {
+      defaultMessage: 'Legal notice - {websiteName}',
+      description: 'LegalNoticePage: SEO - Page title',
+    },
+    { websiteName: config.name }
+  );
+  const pageDescription = intl.formatMessage(
+    {
+      defaultMessage: "Discover the legal notice of {websiteName}'s website.",
+      description: 'LegalNoticePage: SEO - Meta description',
+    },
+    { websiteName: config.name }
+  );
   const pageUrl = `${config.url}${router.asPath}`;
-
+  const title = intl.formatMessage({
+    defaultMessage: 'Legal notice',
+    description: 'LegalNoticePage: page title',
+  });
   const publicationDate = new Date(dates.publication);
   const updateDate = new Date(dates.update);
 
@@ -37,8 +54,8 @@ const LegalNotice: NextPageWithLayout = () => {
     '@id': `${pageUrl}`,
     '@type': 'WebPage',
     breadcrumb: { '@id': `${config.url}/#breadcrumb` },
-    name: seo.legalNotice.title,
-    description: seo.legalNotice.description,
+    name: pageTitle,
+    description: pageDescription,
     inLanguage: config.locales.defaultLocale,
     license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr',
     reviewedBy: { '@id': `${config.url}/#branding` },
@@ -51,7 +68,7 @@ const LegalNotice: NextPageWithLayout = () => {
   const articleSchema: Article = {
     '@id': `${config.url}/#legal-notice`,
     '@type': 'Article',
-    name: t`Legal notice`,
+    name: title,
     description: intro,
     author: { '@id': `${config.url}/#branding` },
     copyrightYear: publicationDate.getFullYear(),
@@ -73,11 +90,11 @@ const LegalNotice: NextPageWithLayout = () => {
   return (
     <>
       <Head>
-        <title>{seo.legalNotice.title}</title>
-        <meta name="description" content={seo.legalNotice.description} />
+        <title>{pageTitle}</title>
+        <meta name="description" content={pageDescription} />
         <meta property="og:url" content={`${pageUrl}`} />
         <meta property="og:type" content="article" />
-        <meta property="og:title" content={t`Legal notice`} />
+        <meta property="og:title" content={pageTitle} />
         <meta property="og:description" content={intro} />
         <script
           type="application/ld+json"
-- 
cgit v1.2.3

