mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-19 07:26:50 +00:00
gitbook 主题fix最近阅读
This commit is contained in:
@@ -5,14 +5,14 @@ import getAllPageIds from '@/lib/notion/getAllPageIds'
|
||||
import { getAllTags } from '@/lib/notion/getAllTags'
|
||||
import { getConfigMapFromConfigPage } from '@/lib/notion/getNotionConfig'
|
||||
import getPageProperties, {
|
||||
adjustPageProperties
|
||||
adjustPageProperties
|
||||
} from '@/lib/notion/getPageProperties'
|
||||
import { fetchInBatches, getPage } from '@/lib/notion/getPostBlocks'
|
||||
import { compressImage, mapImgUrl } from '@/lib/notion/mapImage'
|
||||
import { deepClone } from '@/lib/utils'
|
||||
import { idToUuid } from 'notion-utils'
|
||||
import { siteConfig } from '../config'
|
||||
import { extractLangId, extractLangPrefix } from '../utils/pageId'
|
||||
import { extractLangId, extractLangPrefix, getShortId } from '../utils/pageId'
|
||||
|
||||
export { getAllTags } from '../notion/getAllTags'
|
||||
export { getPost } from '../notion/getNotionPost'
|
||||
@@ -100,16 +100,14 @@ function compressData(db) {
|
||||
// 清理多余的块
|
||||
if (db?.notice) {
|
||||
db.notice = cleanBlock(db?.notice)
|
||||
}
|
||||
if (db?.post) {
|
||||
db.post = cleanBlock(db?.post)
|
||||
delete db.notice?.id
|
||||
}
|
||||
|
||||
db.tagOptions = cleanIds(db?.tagOptions)
|
||||
db.categoryOptions = cleanIds(db?.categoryOptions)
|
||||
db.customMenu = cleanIds(db?.customMenu)
|
||||
|
||||
db.latestPosts = cleanIds(db?.latestPosts)
|
||||
db.latestPosts = shortenIds(db?.latestPosts)
|
||||
db.allNavPages = shortenIds(db?.allNavPages)
|
||||
// db.allPages = cleanBlocks(db?.allPages)
|
||||
|
||||
@@ -125,7 +123,7 @@ function shortenIds(items) {
|
||||
if (items && Array.isArray(items)) {
|
||||
return deepClone(
|
||||
items.map(item => {
|
||||
item.short_id = getFirstPart(item.id)
|
||||
item.short_id = getShortId(item.id)
|
||||
delete item.id
|
||||
return item
|
||||
})
|
||||
@@ -134,16 +132,6 @@ function shortenIds(items) {
|
||||
return items
|
||||
}
|
||||
|
||||
function getFirstPart(uuid) {
|
||||
if (!uuid || uuid.indexOf('-') < 0) {
|
||||
return uuid
|
||||
}
|
||||
// 找到第一个 '-' 的位置
|
||||
const index = uuid.indexOf('-')
|
||||
// 截取从开始到第一个 '-' 之前的部分
|
||||
return uuid.substring(0, index)
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理一组数据的id
|
||||
* @param {*} items
|
||||
@@ -167,7 +155,7 @@ function cleanIds(items) {
|
||||
function cleanBlock(item) {
|
||||
const post = deepClone(item)
|
||||
const pageBlock = post?.blockMap?.block
|
||||
delete post?.id
|
||||
// delete post?.id
|
||||
// delete post?.blockMap?.collection
|
||||
|
||||
if (pageBlock) {
|
||||
|
||||
@@ -30,4 +30,18 @@ function extractLangId(str) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { extractLangPrefix, extractLangId }
|
||||
/**
|
||||
* 列表中用过来区分page只需要端的id足够
|
||||
*/
|
||||
|
||||
function getShortId(uuid) {
|
||||
if (!uuid || uuid.indexOf('-') < 0) {
|
||||
return uuid
|
||||
}
|
||||
// 找到第一个 '-' 的位置
|
||||
const index = uuid.indexOf('-')
|
||||
// 截取从开始到第一个 '-' 之前的部分
|
||||
return uuid.substring(0, index)
|
||||
}
|
||||
|
||||
module.exports = { extractLangPrefix, extractLangId, getShortId }
|
||||
|
||||
Reference in New Issue
Block a user