mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-04 07:26:47 +00:00
优化:POST_URL_PREFIX 和 PSEUDO_STATIC支持在NOTION_CONFIG中配置
This commit is contained in:
@@ -4,11 +4,14 @@ import { getAllCategories } from '@/lib/notion/getAllCategories'
|
||||
import getAllPageIds from '@/lib/notion/getAllPageIds'
|
||||
import { getAllTags } from '@/lib/notion/getAllTags'
|
||||
import { getConfigMapFromConfigPage } from '@/lib/notion/getNotionConfig'
|
||||
import getPageProperties from '@/lib/notion/getPageProperties'
|
||||
import getPageProperties, {
|
||||
adjustPageProperties
|
||||
} from '@/lib/notion/getPageProperties'
|
||||
import { getPostBlocks, getSingleBlock } 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'
|
||||
|
||||
export { getAllTags } from '../notion/getAllTags'
|
||||
@@ -442,14 +445,19 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) {
|
||||
}
|
||||
}
|
||||
|
||||
// 文章计数
|
||||
let postCount = 0
|
||||
|
||||
// 站点配置优先读取配置表格,否则读取blog.config.js 文件
|
||||
const NOTION_CONFIG = (await getConfigMapFromConfigPage(collectionData)) || {}
|
||||
|
||||
// 处理每一条数据的字段
|
||||
collectionData.forEach(function (element) {
|
||||
adjustPageProperties(element, NOTION_CONFIG)
|
||||
})
|
||||
|
||||
const siteInfo = getSiteInfo({ collection, block, pageId })
|
||||
|
||||
// 文章计数
|
||||
let postCount = 0
|
||||
|
||||
// 查找所有的Post和Page
|
||||
const allPages = collectionData.filter(post => {
|
||||
if (post?.type === 'Post' && post.status === 'Published') {
|
||||
@@ -464,7 +472,7 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) {
|
||||
})
|
||||
|
||||
// Sort by date
|
||||
if (BLOG.POSTS_SORT_BY === 'date') {
|
||||
if (siteConfig('POSTS_SORT_BY', '', NOTION_CONFIG) === 'date') {
|
||||
allPages.sort((a, b) => {
|
||||
return b?.publishDate - a?.publishDate
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user