mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-18 07:26:48 +00:00
feat: support whether to distinguish tags by color
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { isIterable } from '../utils'
|
||||
import BLOG from '@/blog'
|
||||
|
||||
/**
|
||||
* 获取所有文章的标签
|
||||
@@ -24,14 +25,30 @@ export function getAllTags({ allPages, sliceCount = 0, tagOptions }) {
|
||||
tagObj[tag] = 1
|
||||
}
|
||||
})
|
||||
|
||||
const list = []
|
||||
const { IS_TAG_COLOR_DISTINGUISHED } = BLOG
|
||||
if (isIterable(tagOptions)) {
|
||||
tagOptions.forEach(c => {
|
||||
const count = tagObj[c.value]
|
||||
if (count) {
|
||||
list.push({ id: c.id, name: c.value, color: c.color, count })
|
||||
}
|
||||
})
|
||||
if (!IS_TAG_COLOR_DISTINGUISHED) {
|
||||
// 如果不区分颜色, 那么不同颜色相同名称的tag当做同一种tag
|
||||
const savedTagNames = new Set()
|
||||
tagOptions.forEach(c => {
|
||||
if (!savedTagNames.has(c.value)) {
|
||||
const count = tagObj[c.value]
|
||||
if (count) {
|
||||
list.push({ id: c.id, name: c.value, color: c.color, count })
|
||||
}
|
||||
savedTagNames.add(c.value)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
tagOptions.forEach(c => {
|
||||
const count = tagObj[c.value]
|
||||
if (count) {
|
||||
list.push({ id: c.id, name: c.value, color: c.color, count })
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 按照数量排序
|
||||
|
||||
Reference in New Issue
Block a user