mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-22 15:09:43 +00:00
feature:
新增标签汇总页
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { rest } from "lodash"
|
||||
|
||||
/**
|
||||
* 获取所有文章的标签
|
||||
* @param allPosts
|
||||
* @param sliceCount 默认截取数量为12,若为0则返回全部
|
||||
* @returns {Promise<{}|*[]>}
|
||||
*/
|
||||
export async function getAllTags (allPosts) {
|
||||
export async function getAllTags (allPosts, sliceCount = 12) {
|
||||
if (!allPosts) {
|
||||
return []
|
||||
}
|
||||
@@ -24,7 +24,13 @@ export async function getAllTags (allPosts) {
|
||||
})
|
||||
|
||||
// 按照标签数量排序
|
||||
const list = Object.keys(tagObj).map((index) => {return {name:index,count:tagObj[index]}})
|
||||
const list = Object.keys(tagObj).map((index) => {
|
||||
return { name: index, count: tagObj[index] }
|
||||
})
|
||||
list.sort((a, b) => b.count - a.count)
|
||||
return list
|
||||
if (sliceCount) {
|
||||
return list.slice(0, 12)
|
||||
} else {
|
||||
return list
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user