feature:加入最新文章功能

This commit is contained in:
tangly1024
2021-11-03 15:48:37 +08:00
parent 58109ee4cd
commit 3fcbb8a420
6 changed files with 60 additions and 26 deletions

View File

@@ -19,7 +19,7 @@ import Custom404 from '@/pages/404'
const mapPageUrl = id => {
return 'https://www.notion.so/' + id.replace(/-/g, '')
}
const BlogPost = ({ post, blockMap, tags, prev, next }) => {
const BlogPost = ({ post, blockMap, tags, prev, next, posts }) => {
if (!post) {
return <Custom404/>
}
@@ -31,7 +31,7 @@ const BlogPost = ({ post, blockMap, tags, prev, next }) => {
const targetRef = useRef(null)
const url = BLOG.link + useRouter().asPath
return <BaseLayout meta={meta} tags={tags} post={post}>
return <BaseLayout meta={meta} tags={tags} post={post} posts={posts}>
{/* 阅读进度条 */}
<Progress targetRef={targetRef} />
@@ -192,7 +192,7 @@ export async function getStaticProps ({ params: { slug } }) {
const next = posts.slice(index + 1, index + 2)[0] ?? posts[0]
return {
props: { post, blockMap, tags, prev, next },
props: { post, blockMap, tags, prev, next, posts },
revalidate: 1
}
}

View File

@@ -27,7 +27,7 @@ export async function getStaticProps () {
const Index = ({ posts, tags, meta }) => {
return (
<BaseLayout meta={meta} tags={tags}>
<BaseLayout meta={meta} tags={tags} posts={posts}>
<div className='flex-grow'>
<TagsBar tags={tags} />
<BlogPostListScroll posts={posts} tags={tags} />