Skip to content

Commit e502f45

Browse files
committed
修复export格式下复杂url的访问bug
1 parent 4837dc4 commit e502f45

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

lib/db/getSiteData.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import getAllPageIds from '@/lib/notion/getAllPageIds'
55
import { getAllTags } from '@/lib/notion/getAllTags'
66
import { getConfigMapFromConfigPage } from '@/lib/notion/getNotionConfig'
77
import getPageProperties, {
8-
adjustPageProperties
8+
adjustPageProperties
99
} from '@/lib/notion/getPageProperties'
1010
import { fetchInBatches, getPage } from '@/lib/notion/getPostBlocks'
1111
import { compressImage, mapImgUrl } from '@/lib/notion/mapImage'
@@ -512,6 +512,7 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) {
512512
adjustPageProperties(element, NOTION_CONFIG)
513513
})
514514

515+
// 站点基础信息
515516
const siteInfo = getSiteInfo({ collection, block, pageId })
516517

517518
// 文章计数

next.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ const locales = (function () {
3232
return langs
3333
})()
3434

35+
// 编译前执行
36+
const preBuild = (function () {
37+
// 删除 public/sitemap.xml 文件 ; 否则会和/pages/sitemap.xml.js 冲突。
38+
const sitemapPath = path.resolve(__dirname, 'public', 'sitemap.xml')
39+
if (fs.existsSync(sitemapPath)) {
40+
fs.unlinkSync(sitemapPath)
41+
console.log('Deleted existing sitemap.xml from public directory')
42+
}
43+
})()
44+
3545
/**
3646
* 扫描指定目录下的文件夹名,用于获取所有主题
3747
* @param {*} directory

pages/[prefix]/[slug]/[...suffix].js

+10-10
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ export async function getStaticPaths() {
3030

3131
const from = 'slug-paths'
3232
const { allPages } = await getGlobalData({ from })
33-
33+
const paths = allPages
34+
?.filter(row => checkSlugHasMorThanTwoSlash(row))
35+
.map(row => ({
36+
params: {
37+
prefix: row.slug.split('/')[0],
38+
slug: row.slug.split('/')[1],
39+
suffix: row.slug.split('/').slice(2)
40+
}
41+
}))
3442
return {
35-
paths: allPages
36-
?.filter(row => checkSlugHasMorThanTwoSlash(row))
37-
.map(row => ({
38-
params: {
39-
prefix: row.slug.split('/')[0],
40-
slug: row.slug.split('/')[1],
41-
suffix: row.slug.split('/').slice(1)
42-
}
43-
})),
43+
paths: paths,
4444
fallback: true
4545
}
4646
}

0 commit comments

Comments
 (0)