diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-09-20 16:38:54 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-09-20 16:38:54 +0200 |
| commit | f861e6a269ba9f62700776d3cd13b644a9e836d4 (patch) | |
| tree | a5a107e7a6e4ff8b4261fe04349357bc00b783ee /src/components/templates/layout/layout.tsx | |
| parent | 03331c44276ec56e9f235e4d5ee75030455a753f (diff) | |
refactor: use named export for everything except pages
Next expect a default export for pages so only those components should
use default exports. Everything else should use named exports to
reduce the number of import statements.
Diffstat (limited to 'src/components/templates/layout/layout.tsx')
| -rw-r--r-- | src/components/templates/layout/layout.tsx | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/src/components/templates/layout/layout.tsx b/src/components/templates/layout/layout.tsx index cf35b5c..beb6562 100644 --- a/src/components/templates/layout/layout.tsx +++ b/src/components/templates/layout/layout.tsx @@ -2,21 +2,29 @@ import Script from 'next/script'; import { FC, ReactElement, ReactNode, useRef, useState } from 'react'; import { useIntl } from 'react-intl'; import { Person, SearchAction, WebSite, WithContext } from 'schema-dts'; -import { type NextPageWithLayoutOptions } from '../../../types/app'; -import useRouteChange from '../../../utils/hooks/use-route-change'; -import useScrollPosition from '../../../utils/hooks/use-scroll-position'; -import useSettings from '../../../utils/hooks/use-settings'; -import ButtonLink from '../../atoms/buttons/button-link'; -import Career from '../../atoms/icons/career'; -import CCBySA from '../../atoms/icons/cc-by-sa'; -import ComputerScreen from '../../atoms/icons/computer-screen'; -import Envelop from '../../atoms/icons/envelop'; -import Home from '../../atoms/icons/home'; -import PostsStack from '../../atoms/icons/posts-stack'; -import Main from '../../atoms/layout/main'; -import NoScript from '../../atoms/layout/no-script'; -import Footer, { type FooterProps } from '../../organisms/layout/footer'; -import Header, { type HeaderProps } from '../../organisms/layout/header'; +import { type NextPageWithLayoutOptions } from '../../../types'; +import { + useRouteChange, + useScrollPosition, + useSettings, +} from '../../../utils/hooks'; +import { + ButtonLink, + Career, + CCBySA, + ComputerScreen, + Envelop, + Home, + Main, + NoScript, + PostsStack, +} from '../../atoms'; +import { + Footer, + type FooterProps, + Header, + type HeaderProps, +} from '../../organisms'; import photo from '/public/armand-philippot.jpg'; import styles from './layout.module.scss'; @@ -44,7 +52,7 @@ export type LayoutProps = Pick<HeaderProps, 'isHome'> & { * * Render the base layout used by all pages. */ -const Layout: FC<LayoutProps> = ({ +export const Layout: FC<LayoutProps> = ({ children, withExtraPadding = false, isHome, @@ -203,14 +211,14 @@ const Layout: FC<LayoutProps> = ({ return ( <> <Script + dangerouslySetInnerHTML={{ __html: JSON.stringify(schemaJsonLd) }} id="schema-layout" type="application/ld+json" - dangerouslySetInnerHTML={{ __html: JSON.stringify(schemaJsonLd) }} /> <Script + dangerouslySetInnerHTML={{ __html: JSON.stringify(brandingSchema) }} id="schema-branding" type="application/ld+json" - dangerouslySetInnerHTML={{ __html: JSON.stringify(brandingSchema) }} /> <noscript> <div className={styles['noscript-spacing']}></div> @@ -239,11 +247,11 @@ const Layout: FC<LayoutProps> = ({ </article> </Main> <Footer + backToTopClassName={backToTopClassName} + className={styles.footer} copyright={copyrightData} navItems={footerNav} topId="top" - backToTopClassName={backToTopClassName} - className={styles.footer} /> <noscript> <NoScript message={noScript} position="top" /> @@ -265,5 +273,3 @@ export const getLayout = ( ) => { return <Layout {...props}>{page}</Layout>; }; - -export default Layout; |
