diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-05-17 22:48:41 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-05-17 22:48:41 +0200 |
| commit | 271ef6debaca7ed9a01829dcef3a37e90a2dff05 (patch) | |
| tree | aa1513b40e7020a44cfcaaedc3a33d39ecfb8af7 /src/pages/index.tsx | |
| parent | 4e53a8654441481029746ff4e35a4a19c8d83709 (diff) | |
chore: use persistent layout
It prevents to rerender the common components between pages (header,
footer...).
Diffstat (limited to 'src/pages/index.tsx')
| -rw-r--r-- | src/pages/index.tsx | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 1143a33..a831ea3 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -13,16 +13,16 @@ import Columns, { import CardsList, { type CardsListItem, } from '@components/organisms/layout/cards-list'; -import Layout from '@components/templates/layout/layout'; +import { getLayout } from '@components/templates/layout/layout'; import HomePageContent from '@content/pages/homepage.mdx'; import { getArticlesCard } from '@services/graphql/articles'; import styles from '@styles/pages/home.module.scss'; -import { ArticleCard } from '@ts/types/app'; +import { type ArticleCard, type NextPageWithLayout } from '@ts/types/app'; import { loadTranslation, type Messages } from '@utils/helpers/i18n'; import useBreadcrumb from '@utils/hooks/use-breadcrumb'; import useSettings from '@utils/hooks/use-settings'; import { NestedMDXComponents } from 'mdx/types'; -import { GetStaticProps, NextPage } from 'next'; +import { GetStaticProps } from 'next'; import Head from 'next/head'; import Script from 'next/script'; import { ReactElement } from 'react'; @@ -37,7 +37,7 @@ type HomeProps = { /** * Home page. */ -const HomePage: NextPage<HomeProps> = ({ recentPosts }) => { +const HomePage: NextPageWithLayout<HomeProps> = ({ recentPosts }) => { const intl = useIntl(); const { schema: breadcrumbSchema } = useBreadcrumb({ title: '', @@ -327,7 +327,7 @@ const HomePage: NextPage<HomeProps> = ({ recentPosts }) => { }; return ( - <Layout breadcrumbSchema={breadcrumbSchema} isHome={true}> + <> <Head> <title>{pageTitle}</title> <meta name="description" content={pageDescription} /> @@ -340,11 +340,19 @@ const HomePage: NextPage<HomeProps> = ({ recentPosts }) => { type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(schemaJsonLd) }} /> + <Script + id="schema-breadcrumb" + type="application/ld+json" + dangerouslySetInnerHTML={{ __html: JSON.stringify(breadcrumbSchema) }} + /> <HomePageContent components={components} /> - </Layout> + </> ); }; +HomePage.getLayout = (page) => + getLayout(page, { isHome: true, withExtraPadding: false }); + export const getStaticProps: GetStaticProps<HomeProps> = async ({ locale }) => { const translation = await loadTranslation(locale); const recentPosts = await getArticlesCard({ first: 3 }); |
