Merge pull request #706 from expoli/dev

[fix] tag 文章数目不对的问题
This commit is contained in:
tangly1024
2023-01-20 12:41:36 +08:00
committed by GitHub
7 changed files with 7 additions and 8 deletions

View File

@@ -43,7 +43,7 @@ export async function getStaticProps({ params: { category } }) {
if (BLOG.POST_LIST_STYLE === 'scroll') {
// 滚动列表 给前端返回所有数据
} else if (BLOG.POST_LIST_STYLE === 'page') {
props.posts = props.posts?.slice(0, BLOG.POSTS_PER_PAGE - 1)
props.posts = props.posts?.slice(0, BLOG.POSTS_PER_PAGE)
}
delete props.allPages

View File

@@ -38,7 +38,7 @@ export async function getStaticProps({ params: { category, page } }) {
// 处理文章页数
props.postCount = props.posts.length
// 处理分页
props.posts = props.posts.slice(BLOG.POSTS_PER_PAGE * (page - 1), BLOG.POSTS_PER_PAGE * page - 1)
props.posts = props.posts.slice(BLOG.POSTS_PER_PAGE * (page - 1), BLOG.POSTS_PER_PAGE * page)
delete props.allPages
props.page = page

View File

@@ -43,7 +43,7 @@ export async function getStaticProps({ params: { keyword } }) {
if (BLOG.POST_LIST_STYLE === 'scroll') {
// 滚动列表 给前端返回所有数据
} else if (BLOG.POST_LIST_STYLE === 'page') {
props.posts = props.posts?.slice(0, BLOG.POSTS_PER_PAGE - 1)
props.posts = props.posts?.slice(0, BLOG.POSTS_PER_PAGE)
}
props.keyword = keyword
return {

View File

@@ -40,7 +40,7 @@ export async function getStaticProps({ params: { keyword, page } }) {
props.posts = await filterByMemCache(allPosts, keyword)
props.postCount = props.posts.length
// 处理分页
props.posts = props.posts.slice(BLOG.POSTS_PER_PAGE * (page - 1), BLOG.POSTS_PER_PAGE * page - 1)
props.posts = props.posts.slice(BLOG.POSTS_PER_PAGE * (page - 1), BLOG.POSTS_PER_PAGE * page)
props.keyword = keyword
props.page = page
delete props.allPages

View File

@@ -55,8 +55,7 @@ export async function getStaticProps() {
pageType: ['Post']
})
const { allPages } = props
const allPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published')
props.posts = allPosts
props.posts = allPages.filter(page => page.type === 'Post' && page.status === 'Published')
return {
props,
revalidate: parseInt(BLOG.NEXT_REVALIDATE_SECOND)

View File

@@ -37,7 +37,7 @@ export async function getStaticProps({ params: { tag } }) {
if (BLOG.POST_LIST_STYLE === 'scroll') {
// 滚动列表 给前端返回所有数据
} else if (BLOG.POST_LIST_STYLE === 'page') {
props.posts = props.posts?.slice(0, BLOG.POSTS_PER_PAGE - 1)
props.posts = props.posts?.slice(0, BLOG.POSTS_PER_PAGE)
}
props.tag = tag

View File

@@ -31,7 +31,7 @@ export async function getStaticProps({ params: { tag, page } }) {
// 处理文章数
props.postCount = props.posts.length
// 处理分页
props.posts = props.posts.slice(BLOG.POSTS_PER_PAGE * (page - 1), BLOG.POSTS_PER_PAGE * page - 1)
props.posts = props.posts.slice(BLOG.POSTS_PER_PAGE * (page - 1), BLOG.POSTS_PER_PAGE * page)
props.tag = tag
props.page = page