修复配置了prefix后,部分页面无法打开的bug

This commit is contained in:
tangly1024.com
2024-06-28 17:31:31 +08:00
parent 3220bf4bf2
commit ea74dc3fae
2 changed files with 10 additions and 5 deletions

View File

@@ -6,9 +6,9 @@ import formatDate from '../utils/formatDate'
import md5 from 'js-md5'
import { siteConfig } from '../config'
import {
checkStartWithHttp,
convertUrlStartWithOneSlash,
getLastSegmentFromUrl
checkStartWithHttp,
convertUrlStartWithOneSlash,
getLastSegmentFromUrl
} from '../utils'
import { extractLangPrefix } from '../utils/pageId'
import { mapImgUrl } from './mapImage'
@@ -290,5 +290,10 @@ function generateCustomizeSlug(postProperties, NOTION_CONFIG) {
if (fullPrefix.endsWith('/')) {
fullPrefix = fullPrefix.substring(0, fullPrefix.length - 1) // 去掉尾部部的"/"
}
return `${fullPrefix}/${postProperties.slug ?? postProperties.id}`
if(fullPrefix){
return `${fullPrefix}/${postProperties.slug ?? postProperties.id}`
}else{
return `${postProperties.slug ?? postProperties.id}`
}
}