From 0f38aee374029213a47ef7c29bd164093fe63c85 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 15 Nov 2023 12:24:42 +0100 Subject: 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. --- src/utils/hooks/use-breadcrumb.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/utils/hooks/use-breadcrumb.ts') diff --git a/src/utils/hooks/use-breadcrumb.ts b/src/utils/hooks/use-breadcrumb.ts index 57c27bd..1cd18d9 100644 --- a/src/utils/hooks/use-breadcrumb.ts +++ b/src/utils/hooks/use-breadcrumb.ts @@ -2,9 +2,9 @@ import { useIntl } from 'react-intl'; import type { BreadcrumbList } from 'schema-dts'; import type { BreadcrumbsItem } from '../../components'; +import { CONFIG } from '../config'; import { ROUTES } from '../constants'; import { slugify } from '../helpers'; -import { useSettings } from './use-settings'; const isArticle = (url: string) => url.startsWith(`${ROUTES.ARTICLE}/`); @@ -61,7 +61,6 @@ export const useBreadcrumb = ({ url, }: useBreadcrumbProps): useBreadcrumbReturn => { const intl = useIntl(); - const { website } = useSettings(); const labels = { home: intl.formatMessage({ defaultMessage: 'Home', @@ -88,7 +87,7 @@ export const useBreadcrumb = ({ '@type': 'ListItem', position: 1, name: labels.home, - item: website.url, + item: CONFIG.url, }, ]; @@ -100,7 +99,7 @@ export const useBreadcrumb = ({ '@type': 'ListItem', position: 2, name: labels.blog, - item: `${website.url}${ROUTES.BLOG}`, + item: `${CONFIG.url}${ROUTES.BLOG}`, }); } @@ -110,7 +109,7 @@ export const useBreadcrumb = ({ '@type': 'ListItem', position: 2, name: labels.projects, - item: `${website.url}${ROUTES.PROJECTS}`, + item: `${CONFIG.url}${ROUTES.PROJECTS}`, }); } @@ -119,7 +118,7 @@ export const useBreadcrumb = ({ '@type': 'ListItem', position: schema.length + 1, name: title, - item: `${website.url}${url}`, + item: `${CONFIG.url}${url}`, }); return { items, schema }; -- cgit v1.2.3