diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-05-16 12:46:38 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-05-16 12:46:38 +0200 |
| commit | 2155550fa36a3bc3c8f66e0926530123b4018cd4 (patch) | |
| tree | 1b7472d7ceeb9c95b2c6de6440b48b94405e155e /src/components/templates/layout/layout.tsx | |
| parent | 8a55aa83bd4b64d1d989cb49b7d9c3fdc1cc6ea5 (diff) | |
refactor: use custom hook for breadcrumb items and schema
Diffstat (limited to 'src/components/templates/layout/layout.tsx')
| -rw-r--r-- | src/components/templates/layout/layout.tsx | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/components/templates/layout/layout.tsx b/src/components/templates/layout/layout.tsx index bfb918b..9e9282b 100644 --- a/src/components/templates/layout/layout.tsx +++ b/src/components/templates/layout/layout.tsx @@ -13,7 +13,13 @@ import useSettings from '@utils/hooks/use-settings'; import Script from 'next/script'; import { FC, ReactNode } from 'react'; import { useIntl } from 'react-intl'; -import { Person, SearchAction, WebSite, WithContext } from 'schema-dts'; +import { + BreadcrumbList, + Person, + SearchAction, + WebSite, + WithContext, +} from 'schema-dts'; import styles from './layout.module.scss'; export type QueryAction = SearchAction & { @@ -22,6 +28,10 @@ export type QueryAction = SearchAction & { export type LayoutProps = Pick<HeaderProps, 'isHome'> & { /** + * The breadcrumb JSON schema. + */ + breadcrumbSchema: BreadcrumbList['itemListElement'][]; + /** * The layout main content. */ children: ReactNode; @@ -36,7 +46,12 @@ export type LayoutProps = Pick<HeaderProps, 'isHome'> & { * * Render the base layout used by all pages. */ -const Layout: FC<LayoutProps> = ({ children, isHome, ...props }) => { +const Layout: FC<LayoutProps> = ({ + breadcrumbSchema, + children, + isHome, + ...props +}) => { const intl = useIntl(); const { website } = useSettings(); const { baseline, copyright, locales, name, picture, url } = website; @@ -153,12 +168,17 @@ const Layout: FC<LayoutProps> = ({ children, isHome, ...props }) => { id="schema-layout" type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(schemaJsonLd) }} - ></Script> + /> <Script id="schema-branding" type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(brandingSchema) }} /> + <Script + id="schema-breadcrumb" + type="application/ld+json" + dangerouslySetInnerHTML={{ __html: JSON.stringify(breadcrumbSchema) }} + /> <noscript> <div className={styles['noscript-spacing']}></div> </noscript> |
