aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/index.tsx
blob: 4146f346eb81fdd3bf2c494b61360a198269a7fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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 { NextPageWithLayout } from '@ts/types/app';
import { HomePage, HomePageProps } from '@ts/types/homepage';
import { loadTranslation } from '@utils/helpers/i18n';
import { getHomePage } from '@services/graphql/queries';

const Home: NextPageWithLayout<HomePageProps> = ({ data }) => {
  return (
    <>
      <Head>
        <title>{seo.homepage.title}</title>
        <meta name="description" content={seo.homepage.description} />
      </Head>
      <div dangerouslySetInnerHTML={{ __html: data.content }}></div>
    </>
  );
};

Home.getLayout = function getLayout(page: ReactElement) {
  return <Layout isHome={true}>{page}</Layout>;
};

export const getStaticProps: GetStaticProps = async (ctx) => {
  const translation = await loadTranslation(
    ctx.locale!,
    process.env.NODE_ENV === 'production'
  );

  const data: HomePage = await getHomePage();

  return {
    props: {
      data,
      translation,
    },
  };
};

export default Home;