@@ -5,14 +5,14 @@ import getAllPageIds from '@/lib/notion/getAllPageIds'
5
5
import { getAllTags } from '@/lib/notion/getAllTags'
6
6
import { getConfigMapFromConfigPage } from '@/lib/notion/getNotionConfig'
7
7
import getPageProperties , {
8
- adjustPageProperties
8
+ adjustPageProperties
9
9
} from '@/lib/notion/getPageProperties'
10
10
import { fetchInBatches , getPage } from '@/lib/notion/getPostBlocks'
11
11
import { compressImage , mapImgUrl } from '@/lib/notion/mapImage'
12
12
import { deepClone } from '@/lib/utils'
13
13
import { idToUuid } from 'notion-utils'
14
14
import { siteConfig } from '../config'
15
- import { extractLangId , extractLangPrefix } from '../utils/pageId'
15
+ import { extractLangId , extractLangPrefix , getShortId } from '../utils/pageId'
16
16
17
17
export { getAllTags } from '../notion/getAllTags'
18
18
export { getPost } from '../notion/getNotionPost'
@@ -100,16 +100,14 @@ function compressData(db) {
100
100
// 清理多余的块
101
101
if ( db ?. notice ) {
102
102
db . notice = cleanBlock ( db ?. notice )
103
- }
104
- if ( db ?. post ) {
105
- db . post = cleanBlock ( db ?. post )
103
+ delete db . notice ?. id
106
104
}
107
105
108
106
db . tagOptions = cleanIds ( db ?. tagOptions )
109
107
db . categoryOptions = cleanIds ( db ?. categoryOptions )
110
108
db . customMenu = cleanIds ( db ?. customMenu )
111
109
112
- db . latestPosts = cleanIds ( db ?. latestPosts )
110
+ db . latestPosts = shortenIds ( db ?. latestPosts )
113
111
db . allNavPages = shortenIds ( db ?. allNavPages )
114
112
// db.allPages = cleanBlocks(db?.allPages)
115
113
@@ -125,7 +123,7 @@ function shortenIds(items) {
125
123
if ( items && Array . isArray ( items ) ) {
126
124
return deepClone (
127
125
items . map ( item => {
128
- item . short_id = getFirstPart ( item . id )
126
+ item . short_id = getShortId ( item . id )
129
127
delete item . id
130
128
return item
131
129
} )
@@ -134,16 +132,6 @@ function shortenIds(items) {
134
132
return items
135
133
}
136
134
137
- function getFirstPart ( uuid ) {
138
- if ( ! uuid || uuid . indexOf ( '-' ) < 0 ) {
139
- return uuid
140
- }
141
- // 找到第一个 '-' 的位置
142
- const index = uuid . indexOf ( '-' )
143
- // 截取从开始到第一个 '-' 之前的部分
144
- return uuid . substring ( 0 , index )
145
- }
146
-
147
135
/**
148
136
* 清理一组数据的id
149
137
* @param {* } items
@@ -167,7 +155,7 @@ function cleanIds(items) {
167
155
function cleanBlock ( item ) {
168
156
const post = deepClone ( item )
169
157
const pageBlock = post ?. blockMap ?. block
170
- delete post ?. id
158
+ // delete post?.id
171
159
// delete post?.blockMap?.collection
172
160
173
161
if ( pageBlock ) {
0 commit comments