diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-09-26 15:54:28 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-10-24 12:23:48 +0200 |
| commit | 70efcfeaa0603415dd992cb662d8efb960e6e49a (patch) | |
| tree | 5d37e98fae9aa7e5c3d8ef30a10db9fed9b63e36 /src/pages/404.tsx | |
| parent | 31695306bfed44409f03006ea717fd2cceff8f87 (diff) | |
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.
Diffstat (limited to 'src/pages/404.tsx')
| -rw-r--r-- | src/pages/404.tsx | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/pages/404.tsx b/src/pages/404.tsx index 67daae1..af95a36 100644 --- a/src/pages/404.tsx +++ b/src/pages/404.tsx @@ -1,6 +1,6 @@ -import { GetStaticProps } from 'next'; +import type { GetStaticProps } from 'next'; import Head from 'next/head'; -import { ReactNode } from 'react'; +import type { ReactNode } from 'react'; import { useIntl } from 'react-intl'; import { getLayout, @@ -15,11 +15,12 @@ import { getTotalThematics, getTotalTopics, } from '../services/graphql'; -import { - type NextPageWithLayout, - type RawThematicPreview, - type RawTopicPreview, +import type { + NextPageWithLayout, + RawThematicPreview, + RawTopicPreview, } from '../types'; +import { ROUTES } from '../utils/constants'; import { getLinksListItems, getPageLinkFromRawData } from '../utils/helpers'; import { loadTranslation, type Messages } from '../utils/helpers/server'; import { useBreadcrumb, useSettings } from '../utils/hooks'; @@ -52,12 +53,12 @@ const Error404Page: NextPageWithLayout<Error404PageProps> = ({ description: 'Error404Page: page body', }, { - link: (chunks: ReactNode) => <Link href="/contact">{chunks}</Link>, + link: (chunks: ReactNode) => <Link href={ROUTES.CONTACT}>{chunks}</Link>, } ); const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumb({ title, - url: `/404`, + url: ROUTES.NOT_FOUND, }); const pageTitle = intl.formatMessage( { @@ -88,6 +89,7 @@ const Error404Page: NextPageWithLayout<Error404PageProps> = ({ <> <Head> <title>{pageTitle}</title> + {/*eslint-disable-next-line react/jsx-no-literals -- Name allowed */} <meta name="description" content={pageDescription} /> </Head> <PageLayout @@ -96,6 +98,7 @@ const Error404Page: NextPageWithLayout<Error404PageProps> = ({ breadcrumbSchema={breadcrumbSchema} widgets={[ <LinksListWidget + // eslint-disable-next-line react/jsx-no-literals -- Key allowed key="thematics-list" items={getLinksListItems( thematicsList.map((thematic) => @@ -106,6 +109,7 @@ const Error404Page: NextPageWithLayout<Error404PageProps> = ({ level={2} />, <LinksListWidget + // eslint-disable-next-line react/jsx-no-literals -- Key allowed key="topics-list" items={getLinksListItems( topicsList.map((topic) => getPageLinkFromRawData(topic, 'topic')) @@ -123,7 +127,7 @@ const Error404Page: NextPageWithLayout<Error404PageProps> = ({ id: 'XKy7rx', })} </p> - <SearchForm isLabelHidden searchPage="/recherche/" /> + <SearchForm isLabelHidden searchPage={ROUTES.SEARCH} /> </PageLayout> </> ); |
