diff options
Diffstat (limited to 'src/pages/contact.tsx')
| -rw-r--r-- | src/pages/contact.tsx | 60 | 
1 files changed, 22 insertions, 38 deletions
| diff --git a/src/pages/contact.tsx b/src/pages/contact.tsx index c0d6c79..2392fe2 100644 --- a/src/pages/contact.tsx +++ b/src/pages/contact.tsx @@ -6,10 +6,15 @@ import SocialMedia from '@components/organisms/widgets/social-media';  import { getLayout } from '@components/templates/layout/layout';  import PageLayout from '@components/templates/page/page-layout';  import { meta } from '@content/pages/contact.mdx'; -import styles from '@styles/pages/contact.module.scss';  import { sendMail } from '@services/graphql/contact'; +import styles from '@styles/pages/contact.module.scss';  import { type NextPageWithLayout } from '@ts/types/app';  import { loadTranslation } from '@utils/helpers/i18n'; +import { +  getSchemaJson, +  getSinglePageSchema, +  getWebPageSchema, +} from '@utils/helpers/schema-org';  import useBreadcrumb from '@utils/hooks/use-breadcrumb';  import useSettings from '@utils/hooks/use-settings';  import { GetStaticProps } from 'next'; @@ -18,7 +23,6 @@ import { useRouter } from 'next/router';  import Script from 'next/script';  import { useState } from 'react';  import { useIntl } from 'react-intl'; -import { ContactPage as ContactPageSchema, Graph, WebPage } from 'schema-dts';  const ContactPage: NextPageWithLayout = () => {    const { dates, intro, seo, title } = meta; @@ -36,43 +40,23 @@ const ContactPage: NextPageWithLayout = () => {    const { website } = useSettings();    const { asPath } = useRouter(); -  const pageUrl = `${website.url}${asPath}`; -  const pagePublicationDate = new Date(dates.publication); -  const pageUpdateDate = dates.update ? new Date(dates.update) : undefined; - -  const webpageSchema: WebPage = { -    '@id': `${pageUrl}`, -    '@type': 'WebPage', -    breadcrumb: { '@id': `${website.url}/#breadcrumb` }, -    name: seo.title, +  const webpageSchema = getWebPageSchema({      description: seo.description, -    reviewedBy: { '@id': `${website.url}/#branding` }, -    url: `${pageUrl}`, -    isPartOf: { -      '@id': `${website.url}`, -    }, -  }; - -  const contactSchema: ContactPageSchema = { -    '@id': `${website.url}/#contact`, -    '@type': 'ContactPage', -    name: title, +    locale: website.locales.default, +    slug: asPath, +    title: seo.title, +    updateDate: dates.update, +  }); +  const contactSchema = getSinglePageSchema({ +    dates,      description: intro, -    author: { '@id': `${website.url}/#branding` }, -    creator: { '@id': `${website.url}/#branding` }, -    dateCreated: pagePublicationDate.toISOString(), -    dateModified: pageUpdateDate && pageUpdateDate.toISOString(), -    datePublished: pagePublicationDate.toISOString(), -    editor: { '@id': `${website.url}/#branding` }, -    inLanguage: website.locales.default, -    license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr', -    mainEntityOfPage: { '@id': `${pageUrl}` }, -  }; - -  const schemaJsonLd: Graph = { -    '@context': 'https://schema.org', -    '@graph': [webpageSchema, contactSchema], -  }; +    id: 'contact', +    kind: 'contact', +    locale: website.locales.default, +    slug: asPath, +    title, +  }); +  const schemaJsonLd = getSchemaJson([webpageSchema, contactSchema]);    const widgets = [      <SocialMedia @@ -134,7 +118,7 @@ const ContactPage: NextPageWithLayout = () => {        <Head>          <title>{`${seo.title} - ${website.name}`}</title>          <meta name="description" content={seo.description} /> -        <meta property="og:url" content={`${pageUrl}`} /> +        <meta property="og:url" content={`${website.url}${asPath}`} />          <meta property="og:type" content="article" />          <meta property="og:title" content={title} />          <meta property="og:description" content={intro} /> | 
