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/contact.tsx | |
| 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/contact.tsx')
| -rw-r--r-- | src/pages/contact.tsx | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/pages/contact.tsx b/src/pages/contact.tsx index 916e04c..f316143 100644 --- a/src/pages/contact.tsx +++ b/src/pages/contact.tsx @@ -16,6 +16,7 @@ import { import { meta } from '../content/pages/contact.mdx'; import { sendMail } from '../services/graphql'; import type { NextPageWithLayout } from '../types'; +import { CONFIG } from '../utils/config'; import { ROUTES } from '../utils/constants'; import { getSchemaJson, @@ -23,7 +24,7 @@ import { getWebPageSchema, } from '../utils/helpers'; import { loadTranslation } from '../utils/helpers/server'; -import { useBreadcrumb, useSettings } from '../utils/hooks'; +import { useBreadcrumb } from '../utils/hooks'; const ContactPage: NextPageWithLayout = () => { const { dates, intro, seo, title } = meta; @@ -44,11 +45,10 @@ const ContactPage: NextPageWithLayout = () => { id: 'Qh2CwH', }); - const { website } = useSettings(); const { asPath } = useRouter(); const webpageSchema = getWebPageSchema({ description: seo.description, - locale: website.locales.default, + locale: CONFIG.locales.defaultLocale, slug: asPath, title: seo.title, updateDate: dates.update, @@ -58,7 +58,7 @@ const ContactPage: NextPageWithLayout = () => { description: intro, id: 'contact', kind: 'contact', - locale: website.locales.default, + locale: CONFIG.locales.defaultLocale, slug: asPath, title, }); @@ -120,7 +120,7 @@ const ContactPage: NextPageWithLayout = () => { const submitMail: ContactFormSubmit = useCallback( async ({ email, message, name, object }) => { const messageHTML = message.replace(/\r?\n/g, '<br />'); - const body = `Message received from ${name} <${email}> on ${website.url}.<br /><br />${messageHTML}`; + const body = `Message received from ${name} <${email}> on ${CONFIG.url}.<br /><br />${messageHTML}`; const replyTo = `${name} <${email}>`; const mailData = { body, @@ -155,11 +155,11 @@ const ContactPage: NextPageWithLayout = () => { validator: () => sent, }; }, - [intl, website.url] + [intl] ); const page = { - title: `${seo.title} - ${website.name}`, - url: `${website.url}${asPath}`, + title: `${seo.title} - ${CONFIG.name}`, + url: `${CONFIG.url}${asPath}`, }; return ( |
