aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/cv.tsx
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/cv.tsx
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/cv.tsx')
-rw-r--r--src/pages/cv.tsx22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/pages/cv.tsx b/src/pages/cv.tsx
index b77aa8c..d08c121 100644
--- a/src/pages/cv.tsx
+++ b/src/pages/cv.tsx
@@ -22,14 +22,14 @@ import { mdxComponents } from '../components/mdx';
import CVContent, { data, meta } from '../content/pages/cv.mdx';
import type { NextPageWithLayout } from '../types';
import { CONFIG } from '../utils/config';
-import { PERSONAL_LINKS, ROUTES } from '../utils/constants';
+import { PERSONAL_LINKS } from '../utils/constants';
import {
getSchemaJson,
getSinglePageSchema,
getWebPageSchema,
} from '../utils/helpers';
import { loadTranslation } from '../utils/helpers/server';
-import { useBreadcrumb, useHeadingsTree } from '../utils/hooks';
+import { useBreadcrumbs, useHeadingsTree } from '../utils/hooks';
const DownloadLink = (chunks: ReactNode) => (
<Link href={data.file} isDownload>
@@ -44,10 +44,8 @@ const CVPage: NextPageWithLayout = () => {
const intl = useIntl();
const { ref, tree } = useHeadingsTree<HTMLDivElement>({ fromLevel: 2 });
const { dates, intro, seo, title } = meta;
- const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumb({
- title,
- url: ROUTES.CV,
- });
+ const { items: breadcrumbItems, schema: breadcrumbSchema } =
+ useBreadcrumbs(title);
const messages = {
image: {
caption: intl.formatMessage(
@@ -115,7 +113,11 @@ const CVPage: NextPageWithLayout = () => {
slug: asPath,
title,
});
- const schemaJsonLd = getSchemaJson([webpageSchema, cvSchema]);
+ const schemaJsonLd = getSchemaJson([
+ webpageSchema,
+ cvSchema,
+ breadcrumbSchema,
+ ]);
const page = {
title: `${seo.title} - ${CONFIG.name}`,
url: `${CONFIG.url}${asPath}`,
@@ -141,12 +143,6 @@ const CVPage: NextPageWithLayout = () => {
type="application/ld+json"
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={title}
intro={intro}