blob: 1c3a5d9d913b759a4d3784bd04918141b960a904 (
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
44
45
46
47
48
49
50
51
|
import { ReactElement } from 'react';
import { GetStaticProps } from 'next';
import Head from 'next/head';
import { t } from '@lingui/macro';
import Layout from '@components/Layouts/Layout';
import { seo } from '@config/seo';
import { config } from '@config/website';
import { getPublishedPosts } from '@services/graphql/blog';
import { NextPageWithLayout } from '@ts/types/app';
import { BlogPageProps } from '@ts/types/blog';
import { loadTranslation } from '@utils/helpers/i18n';
import PostsList from '@components/PostsList/PostsList';
import { SWRConfig } from 'swr';
const Blog: NextPageWithLayout<BlogPageProps> = ({ fallback }) => {
return (
<>
<Head>
<title>{seo.blog.title}</title>
<meta name="description" content={seo.blog.description} />
</Head>
<h1>{t`Blog`}</h1>
<SWRConfig value={{ fallback }}>
<PostsList showYears={true} />
</SWRConfig>
</>
);
};
Blog.getLayout = function getLayout(page: ReactElement) {
return <Layout>{page}</Layout>;
};
export const getStaticProps: GetStaticProps = async (context) => {
const translation = await loadTranslation(
context.locale!,
process.env.NODE_ENV === 'production'
);
const data = await getPublishedPosts({ first: config.postsPerPage });
return {
props: {
fallback: {
'/api/posts': data,
},
translation,
},
};
};
export default Blog;
|