支持让标签按照文章数量倒序排列

This commit is contained in:
tangly1024.com
2024-05-28 11:53:56 +08:00
parent 19bddf1fe9
commit 1614a6ed03
4 changed files with 44 additions and 14 deletions

View File

@@ -5,7 +5,7 @@ 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'
@@ -77,15 +77,17 @@ export async function getNotionPageData({ pageId, from }) {
}
// 返回给前端的数据做处理
return compressData(deepClone(data))
return handleDataBeforeReturn(deepClone(data))
}
/**
* 减少返回给前端的数据
* 脱敏
* 返回给浏览器前端的数据处理
* 适当脱敏
* 减少体积
* 其它处理
* @param {*} db
*/
function compressData(db) {
function handleDataBeforeReturn(db) {
// 清理多余数据
delete db.block
delete db.schema
@@ -545,11 +547,17 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) {
)
})?.[0]
)
// 所有分类
const categoryOptions = getAllCategories({
allPages,
categoryOptions: getCategoryOptions(schema)
})
const tagOptions = getAllTags({ allPages, tagOptions: getTagOptions(schema) })
// 所有标签
const tagOptions = getAllTags({
allPages,
tagOptions: getTagOptions(schema),
NOTION_CONFIG
})
// 旧的菜单
const customNav = getCustomNav({
allPages: collectionData.filter(