From 94f1c1fbea903e677476a167e51b549bb0c53330 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 15 Dec 2021 19:17:11 +0100 Subject: chore: create legal notice view --- src/config/seo.ts | 4 ++++ src/pages/mentions-legales.tsx | 48 ++++++++++++++++++++++++++++++++++++++++++ src/services/graphql/pages.ts | 28 +++++++++++++++++------- src/ts/types/pages.ts | 2 +- 4 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 src/pages/mentions-legales.tsx (limited to 'src') diff --git a/src/config/seo.ts b/src/config/seo.ts index c5853e9..dc75cd2 100644 --- a/src/config/seo.ts +++ b/src/config/seo.ts @@ -13,4 +13,8 @@ export const seo = { title: t`CV Front-end developer | Armand Philippot`, description: t`Discover the curriculum of Armand Philippot, front-end developer located in France: skills, experiences and training.`, }, + legalNotice: { + title: t`Legal notice | Armand Philippot`, + description: t`Discover the ArmandPhilippot.com website legal notice.`, + }, }; diff --git a/src/pages/mentions-legales.tsx b/src/pages/mentions-legales.tsx new file mode 100644 index 0000000..4ff4104 --- /dev/null +++ b/src/pages/mentions-legales.tsx @@ -0,0 +1,48 @@ +import Layout from '@components/Layouts/Layout'; +import { seo } from '@config/seo'; +import { getLegalNoticePage } from '@services/graphql/pages'; +import { NextPageWithLayout } from '@ts/types/app'; +import { PageProps } from '@ts/types/pages'; +import { loadTranslation } from '@utils/helpers/i18n'; +import { GetStaticProps, GetStaticPropsContext } from 'next'; +import Head from 'next/head'; +import { ReactElement } from 'react'; + +const LegalNotice: NextPageWithLayout = ({ page }) => { + return ( + <> + + {seo.legalNotice.title} + + +
+
+

{page.title}

+
+
+
+
+ + ); +}; + +LegalNotice.getLayout = (page: ReactElement) => {page}; + +export const getStaticProps: GetStaticProps = async ( + context: GetStaticPropsContext +) => { + const translation = await loadTranslation( + context.locale!, + process.env.NODE_ENV === 'production' + ); + const page = await getLegalNoticePage(); + + return { + props: { + page, + translation, + }, + }; +}; + +export default LegalNotice; diff --git a/src/services/graphql/pages.ts b/src/services/graphql/pages.ts index 6689e37..0781d44 100644 --- a/src/services/graphql/pages.ts +++ b/src/services/graphql/pages.ts @@ -1,6 +1,6 @@ import { FetchPageByUriReturn, - GetCVPageReturn, + GetPageReturn, Page, PageResponse, RawPage, @@ -35,14 +35,26 @@ const fetchPageByUri: FetchPageByUriReturn = async (uri: string) => { } }; -export const getCVPage: GetCVPageReturn = async () => { - const rawCV = await fetchPageByUri('/cv/'); - - const formattedCV: Page = { - ...rawCV, - content: rawCV.contentParts.afterMore, - intro: rawCV.contentParts.beforeMore, +const getFormattedPage = (page: RawPage) => { + const formattedPage: Page = { + ...page, + content: page.contentParts.afterMore, + intro: page.contentParts.beforeMore, }; + return formattedPage; +}; + +export const getCVPage: GetPageReturn = async () => { + const rawCV = await fetchPageByUri('/cv/'); + const formattedCV = getFormattedPage(rawCV); + return formattedCV; }; + +export const getLegalNoticePage: GetPageReturn = async () => { + const rawLegalNotice = await fetchPageByUri('/mentions-legales'); + const formattedLegalNotice = getFormattedPage(rawLegalNotice); + + return formattedLegalNotice; +}; diff --git a/src/ts/types/pages.ts b/src/ts/types/pages.ts index fa4d05d..4b38ff4 100644 --- a/src/ts/types/pages.ts +++ b/src/ts/types/pages.ts @@ -22,7 +22,7 @@ export type PageResponse = { export type FetchPageByUriReturn = (uri: string) => Promise; -export type GetCVPageReturn = () => Promise; +export type GetPageReturn = () => Promise; export type PageProps = { page: Page; -- cgit v1.2.3