mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
feat(初步实现UUID及其去除-形式重定向到slug):
This commit is contained in:
15
lib/redirect.js
Normal file
15
lib/redirect.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import fs from 'fs'
|
||||
|
||||
export function generateRedirectJson({ allPages }) {
|
||||
let uuidSlugMap = {}
|
||||
allPages.forEach(page => {
|
||||
if (page.type === 'Post' && page.status === 'Published') {
|
||||
uuidSlugMap[page.id] = page.slug
|
||||
}
|
||||
})
|
||||
try {
|
||||
fs.writeFileSync('./public/redirect.json', JSON.stringify(uuidSlugMap))
|
||||
} catch (error) {
|
||||
console.warn('无法写入文件', error)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user