hexo主题 新增category、tag分页

This commit is contained in:
tangly
2022-11-12 22:05:49 +08:00
parent 53dda550b2
commit c3aebd851c
14 changed files with 242 additions and 120 deletions

View File

@@ -12,8 +12,8 @@ const Index = props => {
export async function getStaticProps() {
const from = 'index'
const props = await getGlobalNotionData({ from })
const { allPages, siteInfo } = props
const allPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published')
const { siteInfo } = props
props.posts = props.allPages.filter(page => page.type === 'Post' && page.status === 'Published')
const meta = {
title: `${siteInfo?.title} | ${siteInfo?.description}`,
description: siteInfo?.description,
@@ -21,12 +21,11 @@ export async function getStaticProps() {
slug: '',
type: 'website'
}
// 处理分页
if (BLOG.POST_LIST_STYLE === 'scroll') {
props.posts = Array.from(allPosts)
// 滚动列表默认给前端返回所有数据
} else if (BLOG.POST_LIST_STYLE === 'page') {
props.posts = allPosts?.slice(0, BLOG.POSTS_PER_PAGE)
props.posts = props.posts?.slice(0, BLOG.POSTS_PER_PAGE)
}
// 预览文章内容