From e4d5b8151802517b2943756fc0d09ffa95e2c4e2 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Sat, 29 Jan 2022 18:21:37 +0100 Subject: chore: replace lingui functions with react-intl --- src/pages/index.tsx | 69 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 14 deletions(-) (limited to 'src/pages/index.tsx') diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 264c45a..41a4603 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -2,29 +2,38 @@ import FeedIcon from '@assets/images/icon-feed.svg'; import { ButtonLink } from '@components/Buttons'; import { ContactIcon } from '@components/Icons'; import Layout from '@components/Layouts/Layout'; -import { seo } from '@config/seo'; import { config } from '@config/website'; import HomePageContent from '@content/pages/homepage.mdx'; -import { t } from '@lingui/macro'; import styles from '@styles/pages/Home.module.scss'; import { NextPageWithLayout } from '@ts/types/app'; import { loadTranslation } from '@utils/helpers/i18n'; import { GetStaticProps, GetStaticPropsContext } from 'next'; import Head from 'next/head'; import type { ReactElement } from 'react'; +import { useIntl } from 'react-intl'; import { Graph, WebPage } from 'schema-dts'; const Home: NextPageWithLayout = () => { + const intl = useIntl(); + const CodingLinks = () => { return ( ); @@ -57,10 +66,20 @@ const Home: NextPageWithLayout = () => { return ( ); @@ -72,13 +91,19 @@ const Home: NextPageWithLayout = () => {
  • - {t`Contact me`} + {intl.formatMessage({ + defaultMessage: 'Contact me', + description: 'HomePage: contact button text', + })}
  • - {t`Subscribe`} + {intl.formatMessage({ + defaultMessage: 'Subscribe', + description: 'HomePage: RSS feed subscription text', + })}
  • @@ -92,12 +117,28 @@ const Home: NextPageWithLayout = () => { MoreLinks: MoreLinks, }; + const pageTitle = intl.formatMessage( + { + defaultMessage: '{websiteName} | Front-end developer: WordPress/React', + description: 'HomePage: SEO - Page title', + }, + { websiteName: config.name } + ); + const pageDescription = intl.formatMessage( + { + defaultMessage: + '{websiteName} is a front-end developer located in France. He codes and he writes mostly about web development and open-source.', + description: 'HomePage: SEO - Meta description', + }, + { websiteName: config.name } + ); + const webpageSchema: WebPage = { '@id': `${config.url}/#home`, '@type': 'WebPage', breadcrumb: { '@id': `${config.url}/#breadcrumb` }, - name: seo.legalNotice.title, - description: seo.legalNotice.description, + name: pageTitle, + description: pageDescription, author: { '@id': `${config.url}/#branding` }, creator: { '@id': `${config.url}/#branding` }, editor: { '@id': `${config.url}/#branding` }, @@ -115,12 +156,12 @@ const Home: NextPageWithLayout = () => { return ( <> - {seo.homepage.title} - + {pageTitle} + - - + +