From 271ef6debaca7ed9a01829dcef3a37e90a2dff05 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 17 May 2022 22:48:41 +0200 Subject: chore: use persistent layout It prevents to rerender the common components between pages (header, footer...). --- src/components/templates/page/page-layout.tsx | 35 +++++++++++++-------------- 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'src/components/templates/page/page-layout.tsx') diff --git a/src/components/templates/page/page-layout.tsx b/src/components/templates/page/page-layout.tsx index 2ff2084..d171944 100644 --- a/src/components/templates/page/page-layout.tsx +++ b/src/components/templates/page/page-layout.tsx @@ -21,19 +21,20 @@ import TableOfContents from '@components/organisms/widgets/table-of-contents'; import { type SendCommentVars } from '@services/graphql/api'; import { sendComment } from '@services/graphql/comments'; import useIsMounted from '@utils/hooks/use-is-mounted'; +import Script from 'next/script'; import { FC, HTMLAttributes, ReactNode, useRef, useState } from 'react'; import { useIntl } from 'react-intl'; -import Layout, { type LayoutProps } from '../layout/layout'; +import { BreadcrumbList } from 'schema-dts'; import styles from './page-layout.module.scss'; -export type PageLayoutProps = Pick< - LayoutProps, - 'breadcrumbSchema' | 'isHome' -> & { +export type PageLayoutProps = { /** * True if the page accepts new comments. Default: false. */ allowComments?: boolean; + /** + * Set attributes to the page body. + */ bodyAttributes?: HTMLAttributes; /** * Set additional classnames to the body wrapper. @@ -43,6 +44,10 @@ export type PageLayoutProps = Pick< * The breadcrumb items. */ breadcrumb: BreadcrumbItem[]; + /** + * The breadcrumb JSON schema. + */ + breadcrumbSchema: BreadcrumbList['itemListElement'][]; /** * The main content of the page. */ @@ -98,7 +103,6 @@ const PageLayout: FC = ({ headerMeta, id, intro, - isHome = false, title, widgets, withToC = false, @@ -117,13 +121,7 @@ const PageLayout: FC = ({ const bodyRef = useRef(null); const isMounted = useIsMounted(bodyRef); - const hasComments = Array.isArray(comments) && comments.length > 0; - const articleModifier = - hasComments || allowComments - ? 'article--has-comments' - : 'article--no-comments'; - const [status, setStatus] = useState('info'); const [statusMessage, setStatusMessage] = useState(''); const isReplyRef = useRef(false); @@ -186,11 +184,12 @@ const PageLayout: FC = ({ }; return ( - + <> +