mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-08 07:26:47 +00:00
修复空数据编译问题
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
|
import { isIterable } from '../utils'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有文章的分类
|
* 获取所有文章的分类
|
||||||
* @param allPosts
|
* @param allPosts
|
||||||
* @returns {Promise<{}|*[]>}
|
* @returns {Promise<{}|*[]>}
|
||||||
*/
|
*/
|
||||||
export async function getAllCategories ({ allPosts, categoryOptions, sliceCount = 0 }) {
|
export async function getAllCategories({ allPosts, categoryOptions, sliceCount = 0 }) {
|
||||||
if (!allPosts || !categoryOptions) {
|
if (!allPosts || !categoryOptions) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
@@ -19,12 +21,14 @@ export async function getAllCategories ({ allPosts, categoryOptions, sliceCount
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
const list = []
|
const list = []
|
||||||
categoryOptions.forEach(c => {
|
if (isIterable(categoryOptions)) {
|
||||||
const count = categoryObj[c.value]
|
for (const c of categoryOptions) {
|
||||||
if (count) {
|
const count = categoryObj[c.value]
|
||||||
list.push({ id: c.id, name: c.value, color: c.color, count })
|
if (count) {
|
||||||
|
list.push({ id: c.id, name: c.value, color: c.color, count })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
// 按照数量排序
|
// 按照数量排序
|
||||||
// list.sort((a, b) => b.count - a.count)
|
// list.sort((a, b) => b.count - a.count)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { isIterable } from '../utils'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有文章的标签
|
* 获取所有文章的标签
|
||||||
@@ -6,7 +7,7 @@
|
|||||||
* @param tagOptions tags的下拉选项
|
* @param tagOptions tags的下拉选项
|
||||||
* @returns {Promise<{}|*[]>}
|
* @returns {Promise<{}|*[]>}
|
||||||
*/
|
*/
|
||||||
export async function getAllTags ({ allPosts, sliceCount = 0, tagOptions }) {
|
export async function getAllTags({ allPosts, sliceCount = 0, tagOptions }) {
|
||||||
if (!allPosts || !tagOptions) {
|
if (!allPosts || !tagOptions) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
@@ -22,12 +23,14 @@ export async function getAllTags ({ allPosts, sliceCount = 0, tagOptions }) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
const list = []
|
const list = []
|
||||||
tagOptions.forEach(c => {
|
if (isIterable(tagOptions)) {
|
||||||
const count = tagObj[c.value]
|
tagOptions.forEach(c => {
|
||||||
if (count) {
|
const count = tagObj[c.value]
|
||||||
list.push({ id: c.id, name: c.value, color: c.color, count })
|
if (count) {
|
||||||
}
|
list.push({ id: c.id, name: c.value, color: c.color, count })
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 按照数量排序
|
// 按照数量排序
|
||||||
// list.sort((a, b) => b.count - a.count)
|
// list.sort((a, b) => b.count - a.count)
|
||||||
|
|||||||
Reference in New Issue
Block a user