mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-02 23:16:51 +00:00
完善编译,数据库支持多视图排序
This commit is contained in:
@@ -14,7 +14,7 @@ import { isIterable } from '../utils'
|
||||
* @returns {Promise<{}|*[]>}
|
||||
*/
|
||||
export function getAllCategories({ allPages, categoryOptions, sliceCount = 0 }) {
|
||||
const allPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published')
|
||||
const allPosts = allPages?.filter(page => page.type === 'Post' && page.status === 'Published')
|
||||
if (!allPosts || !categoryOptions) {
|
||||
return []
|
||||
}
|
||||
|
||||
@@ -4,7 +4,15 @@ export default function getAllPageIds (collectionQuery, collectionId, collection
|
||||
return []
|
||||
}
|
||||
let pageIds = []
|
||||
if (collectionQuery && Object.values(collectionQuery).length > 0) {
|
||||
// 优先按照第一个视图排序
|
||||
if (viewIds && viewIds.length > 0) {
|
||||
const ids = collectionView[viewIds[0]].value.page_sort
|
||||
// console.log('PageIds: 从viewId获取', viewIds)
|
||||
for (const id of ids) {
|
||||
pageIds.push(id)
|
||||
}
|
||||
// 否则按照数据库原始排序
|
||||
} else if (collectionQuery && Object.values(collectionQuery).length > 0) {
|
||||
const pageSet = new Set()
|
||||
Object.values(collectionQuery[collectionId]).forEach(view => {
|
||||
view?.blockIds?.forEach(id => pageSet.add(id)) // group视图
|
||||
@@ -12,12 +20,6 @@ export default function getAllPageIds (collectionQuery, collectionId, collection
|
||||
})
|
||||
pageIds = [...pageSet]
|
||||
// console.log('PageIds: 从collectionQuery获取', collectionQuery, pageIds.length)
|
||||
} else if (viewIds && viewIds.length > 0) {
|
||||
const ids = collectionView[viewIds[0]].value.page_sort
|
||||
// console.log('PageIds: 从viewId获取', viewIds)
|
||||
for (const id of ids) {
|
||||
pageIds.push(id)
|
||||
}
|
||||
}
|
||||
return pageIds
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { isIterable } from '../utils'
|
||||
* @returns {Promise<{}|*[]>}
|
||||
*/
|
||||
export function getAllTags({ allPages, sliceCount = 0, tagOptions }) {
|
||||
const allPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published')
|
||||
const allPosts = allPages?.filter(page => page.type === 'Post' && page.status === 'Published')
|
||||
|
||||
if (!allPosts || !tagOptions) {
|
||||
return []
|
||||
|
||||
@@ -180,7 +180,7 @@ function getSiteInfo({ collection, block }) {
|
||||
* @param {*} param0
|
||||
*/
|
||||
export function getNavPages({ allPages }) {
|
||||
const allNavPages = allPages.filter(post => {
|
||||
const allNavPages = allPages?.filter(post => {
|
||||
return post && post?.slug && (!post?.slug?.startsWith('http')) && post?.type === 'Post' && post?.status === 'Published'
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user