diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-11-15 12:24:42 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-15 17:26:16 +0100 |
| commit | 0f38aee374029213a47ef7c29bd164093fe63c85 (patch) | |
| tree | 290cb6471fdfe81e4c42f4da4729247536b04ee7 /src/components/templates/layout | |
| parent | be4d907efb4e2fa658baa7c9b276ed282eb920db (diff) | |
refactor(hooks): remove useSettings hook
It does not make sense to re-export an existing object through a hook.
On some pages both the hook and the object was imported...
It is better to use the CONFIG (previously settings) object directly
and by doing it we avoid potential errors because of conditional hooks.
Diffstat (limited to 'src/components/templates/layout')
| -rw-r--r-- | src/components/templates/layout/layout.tsx | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/components/templates/layout/layout.tsx b/src/components/templates/layout/layout.tsx index 8332ba4..c7b8dbd 100644 --- a/src/components/templates/layout/layout.tsx +++ b/src/components/templates/layout/layout.tsx @@ -15,13 +15,13 @@ import { import { useIntl } from 'react-intl'; import type { Person, SearchAction, WebSite, WithContext } from 'schema-dts'; import type { NextPageWithLayoutOptions } from '../../../types'; +import { CONFIG } from '../../../utils/config'; import { ROUTES } from '../../../utils/constants'; import { useAutofocus, useBoolean, useRouteChange, useScrollPosition, - useSettings, } from '../../../utils/hooks'; import { ButtonLink, @@ -89,8 +89,7 @@ export const Layout: FC<LayoutProps> = ({ }) => { const router = useRouter(); const intl = useIntl(); - const { website } = useSettings(); - const { baseline, copyright, locales, name, url } = website; + const { baseline, copyright, locales, name, url } = CONFIG; const articleGridClass = useGrid ? 'article--grid' : ''; const articleCommentsClass = withExtraPadding ? 'article--padding' : ''; @@ -350,10 +349,10 @@ export const Layout: FC<LayoutProps> = ({ description: baseline, url, author: { '@id': `${url}/#branding` }, - copyrightYear: Number(copyright.start), + copyrightYear: Number(copyright.startYear), creator: { '@id': `${url}/#branding` }, editor: { '@id': `${url}/#branding` }, - inLanguage: locales.default, + inLanguage: locales.defaultLocale, potentialAction: searchActionSchema, }; @@ -469,7 +468,11 @@ export const Layout: FC<LayoutProps> = ({ <Footer className={styles.footer}> <Colophon copyright={ - <Copyright from={copyright.start} owner={name} to={copyright.end} /> + <Copyright + from={copyright.startYear} + owner={name} + to={copyright.endYear} + /> } license={<Icon heading={copyrightTitle} shape="cc-by-sa" size="lg" />} links={footerNav} |
