aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/recherche
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-12-12 18:50:03 +0100
committerArmand Philippot <git@armandphilippot.com>2023-12-12 18:50:03 +0100
commit85c4c42bd601270d7be0f34a0767a34bb85e29bb (patch)
tree16a07a89cf209139672592fd6988f0c028acb7e9 /src/pages/recherche
parent93f87c10783e3d76f1dec667779aedffcae33a39 (diff)
refactor(hooks): rewrite useBreadcrumbs hook
* use next/router to get the slug instead of using props * handle cases where the current page title is not provided * update JSON-LD schema to match the example in documentation * add tests
Diffstat (limited to 'src/pages/recherche')
-rw-r--r--src/pages/recherche/index.tsx19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/pages/recherche/index.tsx b/src/pages/recherche/index.tsx
index 9eaecba..fd7f9e1 100644
--- a/src/pages/recherche/index.tsx
+++ b/src/pages/recherche/index.tsx
@@ -46,7 +46,7 @@ import {
import { loadTranslation, type Messages } from '../../utils/helpers/server';
import {
useArticlesList,
- useBreadcrumb,
+ useBreadcrumbs,
useThematicsList,
useTopicsList,
} from '../../utils/hooks';
@@ -211,10 +211,7 @@ const SearchPage: NextPageWithLayout<SearchPageProps> = ({ data }) => {
},
};
- const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumb({
- title: messages.pageTitle,
- url: ROUTES.SEARCH,
- });
+ const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumbs();
const webpageSchema = getWebPageSchema({
description: messages.seo.metaDesc,
@@ -227,7 +224,11 @@ const SearchPage: NextPageWithLayout<SearchPageProps> = ({ data }) => {
locale: CONFIG.locales.defaultLocale,
slug: asPath,
});
- const schemaJsonLd = getSchemaJson([webpageSchema, blogSchema]);
+ const schemaJsonLd = getSchemaJson([
+ webpageSchema,
+ blogSchema,
+ breadcrumbSchema,
+ ]);
const pageUrl = `${CONFIG.url}${asPath}`;
@@ -250,12 +251,6 @@ const SearchPage: NextPageWithLayout<SearchPageProps> = ({ data }) => {
// eslint-disable-next-line react/no-danger -- Necessary for schema
dangerouslySetInnerHTML={{ __html: JSON.stringify(schemaJsonLd) }}
/>
- <Script
- dangerouslySetInnerHTML={{ __html: JSON.stringify(breadcrumbSchema) }}
- // eslint-disable-next-line react/jsx-no-literals -- Id allowed
- id="schema-breadcrumb"
- type="application/ld+json"
- />
<PageHeader
heading={messages.pageTitle}
meta={{ total: articles ? articles[0].pageInfo.total : undefined }}