diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/config/seo.ts | 4 | ||||
| -rw-r--r-- | src/pages/mentions-legales.tsx | 48 | ||||
| -rw-r--r-- | src/services/graphql/pages.ts | 28 | ||||
| -rw-r--r-- | src/ts/types/pages.ts | 2 |
4 files changed, 73 insertions, 9 deletions
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<PageProps> = ({ page }) => { + return ( + <> + <Head> + <title>{seo.legalNotice.title}</title> + <meta name="description" content={seo.legalNotice.description} /> + </Head> + <article> + <header> + <h1>{page.title}</h1> + <div dangerouslySetInnerHTML={{ __html: page.intro }}></div> + </header> + <div dangerouslySetInnerHTML={{ __html: page.content }}></div> + </article> + </> + ); +}; + +LegalNotice.getLayout = (page: ReactElement) => <Layout>{page}</Layout>; + +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<RawPage>; -export type GetCVPageReturn = () => Promise<Page>; +export type GetPageReturn = () => Promise<Page>; export type PageProps = { page: Page; |
