diff options
Diffstat (limited to 'src/pages/index.tsx')
| -rw-r--r-- | src/pages/index.tsx | 90 |
1 files changed, 65 insertions, 25 deletions
diff --git a/src/pages/index.tsx b/src/pages/index.tsx index ae5fe4b..41a4603 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,30 +1,39 @@ -import type { ReactElement } from 'react'; -import { GetStaticProps, GetStaticPropsContext } from 'next'; -import Head from 'next/head'; +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 { NextPageWithLayout } from '@ts/types/app'; -import { defaultLocale, loadTranslation } from '@utils/helpers/i18n'; +import { config } from '@config/website'; import HomePageContent from '@content/pages/homepage.mdx'; -import { ButtonLink } from '@components/Buttons'; import styles from '@styles/pages/Home.module.scss'; -import { t } from '@lingui/macro'; -import FeedIcon from '@assets/images/icon-feed.svg'; -import { ContactIcon } from '@components/Icons'; +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'; -import { config } from '@config/website'; const Home: NextPageWithLayout = () => { + const intl = useIntl(); + const CodingLinks = () => { return ( <ul className={styles['links-list']}> <li> <ButtonLink target="/thematique/developpement-web"> - {t`Web development`} + {intl.formatMessage({ + defaultMessage: 'Web development', + description: 'HomePage: link to web development thematic', + })} </ButtonLink> </li> <li> - <ButtonLink target="/projets">{t`Projects`}</ButtonLink> + <ButtonLink target="/projets"> + {intl.formatMessage({ + defaultMessage: 'Projects', + description: 'HomePage: link to projects', + })} + </ButtonLink> </li> </ul> ); @@ -57,10 +66,20 @@ const Home: NextPageWithLayout = () => { return ( <ul className={styles['links-list']}> <li> - <ButtonLink target="/thematique/libre">{t`Free`}</ButtonLink> + <ButtonLink target="/thematique/libre"> + {intl.formatMessage({ + defaultMessage: 'Free', + description: 'HomePage: link to free thematic', + })} + </ButtonLink> </li> <li> - <ButtonLink target="/thematique/linux">{t`Linux`}</ButtonLink> + <ButtonLink target="/thematique/linux"> + {intl.formatMessage({ + defaultMessage: 'Linux', + description: 'HomePage: link to Linux thematic', + })} + </ButtonLink> </li> </ul> ); @@ -72,13 +91,19 @@ const Home: NextPageWithLayout = () => { <li> <ButtonLink target="/contact"> <ContactIcon /> - {t`Contact me`} + {intl.formatMessage({ + defaultMessage: 'Contact me', + description: 'HomePage: contact button text', + })} </ButtonLink> </li> <li> <ButtonLink target="/feed"> <FeedIcon className={styles['icon--feed']} /> - {t`Subscribe`} + {intl.formatMessage({ + defaultMessage: 'Subscribe', + description: 'HomePage: RSS feed subscription text', + })} </ButtonLink> </li> </ul> @@ -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 ( <> <Head> - <title>{seo.homepage.title}</title> - <meta name="description" content={seo.homepage.description} /> + <title>{pageTitle}</title> + <meta name="description" content={pageDescription} /> <meta property="og:type" content="website" /> <meta property="og:url" content={`${config.url}`} /> - <meta property="og:title" content={seo.homepage.title} /> - <meta property="og:description" content={seo.homepage.description} /> + <meta property="og:title" content={pageTitle} /> + <meta property="og:description" content={pageDescription} /> <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(schemaJsonLd) }} @@ -141,11 +182,10 @@ export const getStaticProps: GetStaticProps = async ( context: GetStaticPropsContext ) => { const { locale } = context; - const translation = await loadTranslation(locale || defaultLocale); + const translation = await loadTranslation(locale); return { props: { - locale, translation, }, }; |
