From 5bc55ac0a801cbe82c41a10f7e680612be4deaf8 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Mon, 13 Dec 2021 16:42:50 +0100
Subject: chore: create homepage with graphql data

---
 src/pages/index.tsx | 80 ++++++++++-------------------------------------------
 1 file changed, 15 insertions(+), 65 deletions(-)

(limited to 'src/pages/index.tsx')

diff --git a/src/pages/index.tsx b/src/pages/index.tsx
index 615fe0a..6654617 100644
--- a/src/pages/index.tsx
+++ b/src/pages/index.tsx
@@ -1,75 +1,22 @@
+import type { ReactElement } from 'react';
+import { GetStaticProps } from 'next';
+import Head from 'next/head';
 import Layout from '@components/Layouts/Layout';
+import { seo } from '@config/seo';
+import { getHomePage } from '@services/graphql/homepage';
 import { NextPageWithLayout } from '@ts/types/app';
+import { HomePage, HomePageProps } from '@ts/types/homepage';
 import { loadTranslation } from '@utils/helpers/i18n';
-import { GetStaticProps } from 'next';
-import Head from 'next/head';
-import Image from 'next/image';
-import type { ReactElement } from 'react';
-import styles from '../styles/Home.module.css';
 
-const Home: NextPageWithLayout = () => {
+const Home: NextPageWithLayout<HomePageProps> = ({ data }) => {
   return (
-    <div className={styles.container}>
+    <>
       <Head>
-        <title>Create Next App</title>
-        <meta name="description" content="Generated by create next app" />
-        <link rel="icon" href="/favicon.ico" />
+        <title>{seo.homepage.title}</title>
+        <meta name="description" content={seo.homepage.description} />
       </Head>
-
-      <main className={styles.main}>
-        <h1 className={styles.title}>
-          Welcome to <a href="https://nextjs.org">Next.js!</a>
-        </h1>
-
-        <p className={styles.description}>
-          Get started by editing{' '}
-          <code className={styles.code}>pages/index.tsx</code>
-        </p>
-
-        <div className={styles.grid}>
-          <a href="https://nextjs.org/docs" className={styles.card}>
-            <h2>Documentation &rarr;</h2>
-            <p>Find in-depth information about Next.js features and API.</p>
-          </a>
-
-          <a href="https://nextjs.org/learn" className={styles.card}>
-            <h2>Learn &rarr;</h2>
-            <p>Learn about Next.js in an interactive course with quizzes!</p>
-          </a>
-
-          <a
-            href="https://github.com/vercel/next.js/tree/master/examples"
-            className={styles.card}
-          >
-            <h2>Examples &rarr;</h2>
-            <p>Discover and deploy boilerplate example Next.js projects.</p>
-          </a>
-
-          <a
-            href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
-            className={styles.card}
-          >
-            <h2>Deploy &rarr;</h2>
-            <p>
-              Instantly deploy your Next.js site to a public URL with Vercel.
-            </p>
-          </a>
-        </div>
-      </main>
-
-      <footer className={styles.footer}>
-        <a
-          href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
-          target="_blank"
-          rel="noopener noreferrer"
-        >
-          Powered by{' '}
-          <span className={styles.logo}>
-            <Image src="/vercel.svg" alt="Vercel Logo" width={72} height={16} />
-          </span>
-        </a>
-      </footer>
-    </div>
+      <div dangerouslySetInnerHTML={{ __html: data.content }}></div>
+    </>
   );
 };
 
@@ -83,8 +30,11 @@ export const getStaticProps: GetStaticProps = async (ctx) => {
     process.env.NODE_ENV === 'production'
   );
 
+  const data: HomePage = await getHomePage();
+
   return {
     props: {
+      data,
       translation,
     },
   };
-- 
cgit v1.2.3

