From 70b4f633a6fbedb58c8b9134ac64ede854d489de Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 20 Nov 2023 12:27:46 +0100 Subject: refactor(components): replace PageLayout template with Page * split pages in smaller components (it is both easier to maintain and more readable, we avoid the use of fragments in pages directory) * extract breadcrumbs from article tag (the navigation is not related to the page contents) * remove useReadingTime hook * remove layout options except `isHome` --- src/pages/cv.tsx | 160 ++++++++++++++++++++++++++----------------------------- 1 file changed, 76 insertions(+), 84 deletions(-) (limited to 'src/pages/cv.tsx') diff --git a/src/pages/cv.tsx b/src/pages/cv.tsx index 0cda194..fd19a83 100644 --- a/src/pages/cv.tsx +++ b/src/pages/cv.tsx @@ -17,12 +17,13 @@ import { ImageWidget, Link, List, - PageLayout, SocialMediaWidget, ListItem, - Time, - MetaList, - MetaItem, + Page, + PageHeader, + PageSidebar, + TocWidget, + PageBody, } from '../components'; import CVContent, { data, meta } from '../content/pages/cv.mdx'; import type { NextPageWithLayout } from '../types'; @@ -34,7 +35,7 @@ import { getWebPageSchema, } from '../utils/helpers'; import { loadTranslation } from '../utils/helpers/server'; -import { useBreadcrumb } from '../utils/hooks'; +import { useBreadcrumb, useHeadingsTree } from '../utils/hooks'; const ExternalLink = ({ children = '', @@ -137,6 +138,7 @@ const components: MDXComponents = { */ const CVPage: NextPageWithLayout = () => { const intl = useIntl(); + const { ref, tree } = useHeadingsTree({ fromLevel: 2 }); const { file, image } = data; const { dates, intro, seo, title } = meta; const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumb({ @@ -154,6 +156,11 @@ const CVPage: NextPageWithLayout = () => { description: 'CVPage: social media widget title', id: '+Dre5J', }); + const tocTitle = intl.formatMessage({ + defaultMessage: 'Table of Contents', + description: 'PageLayout: table of contents title', + id: 'eys2uX', + }); const cvCaption = intl.formatMessage( { @@ -186,49 +193,6 @@ const CVPage: NextPageWithLayout = () => { id: 'Sm2wCk', }); - const widgets = [ - - {imageWidgetTitle} - - } - img={} - // eslint-disable-next-line react/jsx-no-literals -- Key allowed - key="image-widget" - />, - - {socialMediaTitle} - - } - // eslint-disable-next-line react/jsx-no-literals -- Key allowed - key="social-media" - media={[ - { - icon: 'Github', - id: 'github', - label: githubLabel, - url: PERSONAL_LINKS.GITHUB, - }, - { - icon: 'Gitlab', - id: 'gitlab', - label: gitlabLabel, - url: PERSONAL_LINKS.GITLAB, - }, - { - icon: 'LinkedIn', - id: 'linkedin', - label: linkedinLabel, - url: PERSONAL_LINKS.LINKEDIN, - }, - ]} - />, - ]; - const { asPath } = useRouter(); const webpageSchema = getWebPageSchema({ description: seo.description, @@ -254,38 +218,7 @@ const CVPage: NextPageWithLayout = () => { }; return ( - - } - /> - {dates.update ? ( - } - /> - ) : null} - - } - intro={intro} - title={title} - widgets={widgets} - withToC={true} - > + {page.title} {/*eslint-disable-next-line react/jsx-no-literals -- Name allowed */} @@ -304,13 +237,72 @@ const CVPage: NextPageWithLayout = () => { type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(schemaJsonLd) }} /> - - +