Skip to content

Commit ea74dc3

Browse files
committed
修复配置了prefix后,部分页面无法打开的bug
1 parent 3220bf4 commit ea74dc3

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lib/notion/getPageProperties.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import formatDate from '../utils/formatDate'
66
import md5 from 'js-md5'
77
import { siteConfig } from '../config'
88
import {
9-
checkStartWithHttp,
10-
convertUrlStartWithOneSlash,
11-
getLastSegmentFromUrl
9+
checkStartWithHttp,
10+
convertUrlStartWithOneSlash,
11+
getLastSegmentFromUrl
1212
} from '../utils'
1313
import { extractLangPrefix } from '../utils/pageId'
1414
import { mapImgUrl } from './mapImage'
@@ -290,5 +290,10 @@ function generateCustomizeSlug(postProperties, NOTION_CONFIG) {
290290
if (fullPrefix.endsWith('/')) {
291291
fullPrefix = fullPrefix.substring(0, fullPrefix.length - 1) // 去掉尾部部的"/"
292292
}
293-
return `${fullPrefix}/${postProperties.slug ?? postProperties.id}`
293+
294+
if(fullPrefix){
295+
return `${fullPrefix}/${postProperties.slug ?? postProperties.id}`
296+
}else{
297+
return `${postProperties.slug ?? postProperties.id}`
298+
}
294299
}

pages/[prefix]/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export async function getStaticProps({ params: { prefix }, locale }) {
129129
fullSlug += '.html'
130130
}
131131
}
132-
132+
133133
// 在列表内查找文章
134134
props.post = props?.allPages?.find(p => {
135135
return (

0 commit comments

Comments
 (0)