Files
NotionNext/pages/index.js
tangly1024 255a774e1c feature:
首页、文章页背景色微调;
侧边抽屉完善;
标签组长度调整;
最近文章日期格式化,增加路由高亮,封装;
清除冗余代码;
2021-11-03 17:40:19 +08:00

40 lines
1009 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 bg-gray-200 dark:bg-black'>
<TagsBar tags={tags} />
<BlogPostListScroll posts={posts} tags={tags} />
</div>
</BaseLayout>
)
}
export default Index