mirror of
https://github.com/usememos/memos.git
synced 2025-03-18 11:40:09 +01:00
fix: tag stats
This commit is contained in:
parent
d9d6f73330
commit
012ca1d780
@ -59,12 +59,17 @@ export const useMemoTagList = () => {
|
||||
const memos = Object.values(memoStore.getState().dataMapByName);
|
||||
const tagAmounts: Record<string, number> = {};
|
||||
memos.forEach((memo) => {
|
||||
memo.tags.forEach((tag) => {
|
||||
if (tagAmounts[tag]) {
|
||||
tagAmounts[tag] += 1;
|
||||
} else {
|
||||
tagAmounts[tag] = 1;
|
||||
const tagSet = new Set<string>();
|
||||
for (const tag of memo.tags) {
|
||||
const parts = tag.split("/");
|
||||
let currentTag = "";
|
||||
for (const part of parts) {
|
||||
currentTag = currentTag ? `${currentTag}/${part}` : part;
|
||||
tagSet.add(currentTag);
|
||||
}
|
||||
}
|
||||
Array.from(tagSet).forEach((tag) => {
|
||||
tagAmounts[tag] = tagAmounts[tag] ? tagAmounts[tag] + 1 : 1;
|
||||
});
|
||||
});
|
||||
return tagAmounts;
|
||||
|
Loading…
x
Reference in New Issue
Block a user