Merge pull request #553 from tangly1024/main

发布tanlgy1024.com
This commit is contained in:
tangly1024
2022-12-08 12:27:16 +08:00
committed by GitHub
2 changed files with 12 additions and 9 deletions

View File

@@ -78,7 +78,7 @@ export default async function getPageProperties(id, block, schema, authToken, ta
// 开启伪静态路径 // 开启伪静态路径
if (BLOG.PSEUDO_STATIC) { if (BLOG.PSEUDO_STATIC) {
if (!properties.slug.endsWith('.html')) { if (!properties?.slug?.endsWith('.html') && !properties?.slug?.startsWith('http')) {
properties.slug += '.html' properties.slug += '.html'
} }
} }

View File

@@ -124,14 +124,17 @@ export async function getStaticProps({ params: { slug } }) {
} }
const allPosts = props.allPages.filter(page => page.type === 'Post' && page.status === 'Published') const allPosts = props.allPages.filter(page => page.type === 'Post' && page.status === 'Published')
if (allPosts && allPosts.length > 0) {
const index = allPosts.indexOf(props.post) const index = allPosts.indexOf(props.post)
props.prev = allPosts.slice(index - 1, index)[0] ?? allPosts.slice(-1)[0] props.prev = allPosts.slice(index - 1, index)[0] ?? allPosts.slice(-1)[0]
props.next = allPosts.slice(index + 1, index + 2)[0] ?? allPosts[0] props.next = allPosts.slice(index + 1, index + 2)[0] ?? allPosts[0]
props.recommendPosts = getRecommendPost( props.recommendPosts = getRecommendPost(props.post, allPosts, BLOG.POST_RECOMMEND_COUNT)
props.post, } else {
allPosts, props.prev = null
BLOG.POST_RECOMMEND_COUNT props.next = null
) props.recommendPosts = []
}
delete props.allPages delete props.allPages
return { return {
props, props,