2021-01-09 17:50:45 +08:00
|
|
|
import { getAllFilesFrontMatter } from '@/lib/mdx'
|
|
|
|
import siteMetadata from '@/data/siteMetadata'
|
|
|
|
import ListLayout from '@/layouts/ListLayout'
|
2021-01-10 17:35:37 +08:00
|
|
|
import { PageSeo } from '@/components/SEO'
|
2021-01-09 17:50:45 +08:00
|
|
|
|
2021-05-26 16:56:19 +03:00
|
|
|
export const POSTS_PER_PAGE = 10
|
|
|
|
|
2021-01-09 17:50:45 +08:00
|
|
|
export async function getStaticProps() {
|
2021-05-26 16:56:19 +03:00
|
|
|
const getPosts = await getAllFilesFrontMatter('blog')
|
|
|
|
const posts = getPosts.splice(0, POSTS_PER_PAGE)
|
|
|
|
const pagination = {
|
|
|
|
currentPage: 1,
|
|
|
|
totalPages: Math.ceil(getPosts.length / POSTS_PER_PAGE) + 1,
|
|
|
|
}
|
2021-01-09 17:50:45 +08:00
|
|
|
|
2021-05-26 16:56:19 +03:00
|
|
|
return { props: { posts, pagination } }
|
2021-01-09 17:50:45 +08:00
|
|
|
}
|
|
|
|
|
2021-05-26 16:56:19 +03:00
|
|
|
export default function Blog({ posts, pagination }) {
|
2021-01-09 17:50:45 +08:00
|
|
|
return (
|
|
|
|
<>
|
2021-01-10 17:35:37 +08:00
|
|
|
<PageSeo
|
2021-01-10 14:32:35 +08:00
|
|
|
title={`Blog - ${siteMetadata.author}`}
|
2021-01-09 17:50:45 +08:00
|
|
|
description={siteMetadata.description}
|
2021-01-10 17:35:37 +08:00
|
|
|
url={`${siteMetadata.siteUrl}/blog`}
|
2021-01-09 17:50:45 +08:00
|
|
|
/>
|
2021-05-26 16:56:19 +03:00
|
|
|
<ListLayout posts={posts} pagination={pagination} title="All Posts" />
|
2021-01-09 17:50:45 +08:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|