Files
NotionNext/pages/index.js
2021-11-03 15:48:37 +08:00

40 lines
983 B
JavaScript

import { getAllPosts, getAllTags } from '@/lib/notion'
import BLOG from '@/blog.config'
import BaseLayout from '@/layouts/BaseLayout'
import TagsBar from '@/components/TagsBar'
import BlogPostListScroll from '@/components/BlogPostListScroll'
export async function getStaticProps () {
let posts = await getAllPosts({ from: 'index' })
posts = posts.filter(
post => post.status[0] === 'Published' && post.type[0] === 'Post'
)
const tags = await getAllTags(posts)
const meta = {
title: `${BLOG.title} | ${BLOG.description} `,
description: BLOG.description,
type: 'website'
}
return {
props: {
posts,
tags,
meta
},
revalidate: 1
}
}
const Index = ({ posts, tags, meta }) => {
return (
<BaseLayout meta={meta} tags={tags} posts={posts}>
<div className='flex-grow'>
<TagsBar tags={tags} />
<BlogPostListScroll posts={posts} tags={tags} />
</div>
</BaseLayout>
)
}
export default Index