mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-05 15:10:26 +00:00
标签排序
奖赏按钮 搜索框按钮加载动画 EndSlogan排版 notion-viewport处理
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { rest } from "lodash"
|
||||
|
||||
/**
|
||||
* 获取所有文章的标签
|
||||
* @param allPosts
|
||||
@@ -10,6 +12,8 @@ export async function getAllTags (allPosts) {
|
||||
|
||||
let tags = allPosts.map(p => p.tags)
|
||||
tags = [...tags.flat()]
|
||||
|
||||
// 标签计数
|
||||
const tagObj = {}
|
||||
tags.forEach(tag => {
|
||||
if (tag in tagObj) {
|
||||
@@ -18,5 +22,9 @@ export async function getAllTags (allPosts) {
|
||||
tagObj[tag] = 1
|
||||
}
|
||||
})
|
||||
return tagObj
|
||||
|
||||
// 按照标签数量排序
|
||||
const list = Object.keys(tagObj).map((index) => {return {name:index,count:tagObj[index]}})
|
||||
list.sort((a, b) => b.count - a.count)
|
||||
return list
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user