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/pages/recherche | |
| 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/pages/recherche')
| -rw-r--r-- | src/pages/recherche/index.tsx | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/pages/recherche/index.tsx b/src/pages/recherche/index.tsx index 87e6171..92035b0 100644 --- a/src/pages/recherche/index.tsx +++ b/src/pages/recherche/index.tsx @@ -31,6 +31,7 @@ import type { RawThematicPreview, RawTopicPreview, } from '../../types'; +import { CONFIG } from '../../utils/config'; import { ROUTES } from '../../utils/constants'; import { getBlogSchema, @@ -40,12 +41,7 @@ import { getWebPageSchema, } from '../../utils/helpers'; import { loadTranslation, type Messages } from '../../utils/helpers/server'; -import { - useBreadcrumb, - useDataFromAPI, - usePostsList, - useSettings, -} from '../../utils/hooks'; +import { useBreadcrumb, useDataFromAPI, usePostsList } from '../../utils/hooks'; type SearchPageProps = { thematicsList: RawThematicPreview[]; @@ -81,10 +77,9 @@ const SearchPage: NextPageWithLayout<SearchPageProps> = ({ url: ROUTES.SEARCH, }); - const { blog, website } = useSettings(); const page = { - title: `${title} - ${website.name}`, - url: `${website.url}${asPath}`, + title: `${title} - ${CONFIG.name}`, + url: `${CONFIG.url}${asPath}`, }; const pageDescription = query.s ? intl.formatMessage( @@ -94,7 +89,7 @@ const SearchPage: NextPageWithLayout<SearchPageProps> = ({ description: 'SearchPage: SEO - Meta description', id: 'pg26sn', }, - { query: query.s as string, websiteName: website.name } + { query: query.s as string, websiteName: CONFIG.name } ) : intl.formatMessage( { @@ -102,17 +97,17 @@ const SearchPage: NextPageWithLayout<SearchPageProps> = ({ description: 'SearchPage: SEO - Meta description', id: 'npisb3', }, - { websiteName: website.name } + { websiteName: CONFIG.name } ); const webpageSchema = getWebPageSchema({ description: pageDescription, - locale: website.locales.default, + locale: CONFIG.locales.defaultLocale, slug: asPath, title: page.title, }); const blogSchema = getBlogSchema({ isSinglePage: false, - locale: website.locales.default, + locale: CONFIG.locales.defaultLocale, slug: asPath, }); const schemaJsonLd = getSchemaJson([webpageSchema, blogSchema]); @@ -129,7 +124,7 @@ const SearchPage: NextPageWithLayout<SearchPageProps> = ({ } = usePostsList({ fallback: [], fetcher: getArticles, - perPage: blog.postsPerPage, + perPage: CONFIG.postsPerPage, searchQuery: query.s as string, }); |
