From 70efcfeaa0603415dd992cb662d8efb960e6e49a Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 26 Sep 2023 15:54:28 +0200 Subject: refactor(routes): replace hardcoded routes with constants It makes it easier to change a route if needed and it avoid typo mistakes. I also refactored a bit the concerned files to be complient with the new ESlint config. However, I should rewrite the pages to reduce the number of statements. --- src/pages/mentions-legales.tsx | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'src/pages/mentions-legales.tsx') diff --git a/src/pages/mentions-legales.tsx b/src/pages/mentions-legales.tsx index faf76b1..9b0cc98 100644 --- a/src/pages/mentions-legales.tsx +++ b/src/pages/mentions-legales.tsx @@ -1,5 +1,5 @@ -import { MDXComponents } from 'mdx/types'; -import { GetStaticProps } from 'next'; +import type { MDXComponents } from 'mdx/types'; +import type { GetStaticProps } from 'next'; import Head from 'next/head'; import { useRouter } from 'next/router'; import Script from 'next/script'; @@ -7,11 +7,12 @@ import { getLayout, Link, PageLayout, - type PageLayoutProps, ResponsiveImage, + type MetaData, } from '../components'; import LegalNoticeContent, { meta } from '../content/pages/legal-notice.mdx'; -import { type NextPageWithLayout } from '../types'; +import type { NextPageWithLayout } from '../types'; +import { ROUTES } from '../utils/constants'; import { getSchemaJson, getSinglePageSchema, @@ -20,6 +21,11 @@ import { import { loadTranslation } from '../utils/helpers/server'; import { useBreadcrumb, useSettings } from '../utils/hooks'; +const components: MDXComponents = { + Image: ResponsiveImage, + Link, +}; + /** * Legal Notice page. */ @@ -27,10 +33,10 @@ const LegalNoticePage: NextPageWithLayout = () => { const { dates, intro, seo, title } = meta; const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumb({ title, - url: `/mentions-legales`, + url: ROUTES.LEGAL_NOTICE, }); - const headerMeta: PageLayoutProps['headerMeta'] = { + const headerMeta: MetaData = { publication: { date: dates.publication, }, @@ -41,11 +47,6 @@ const LegalNoticePage: NextPageWithLayout = () => { : undefined, }; - const components: MDXComponents = { - Image: ResponsiveImage, - Link, - }; - const { website } = useSettings(); const { asPath } = useRouter(); const webpageSchema = getWebPageSchema({ @@ -65,6 +66,10 @@ const LegalNoticePage: NextPageWithLayout = () => { title, }); const schemaJsonLd = getSchemaJson([webpageSchema, articleSchema]); + const page = { + title: `${seo.title} - ${website.name}`, + url: `${website.url}${asPath}`, + }; return ( { withToC={true} > - {`${seo.title} - ${website.name}`} + {page.title} + {/*eslint-disable-next-line react/jsx-no-literals -- Name allowed */} - + + {/*eslint-disable-next-line react/jsx-no-literals -- Content allowed */} - +