mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
fix: tag stats
This commit is contained in:
@@ -59,12 +59,17 @@ export const useMemoTagList = () => {
|
|||||||
const memos = Object.values(memoStore.getState().dataMapByName);
|
const memos = Object.values(memoStore.getState().dataMapByName);
|
||||||
const tagAmounts: Record<string, number> = {};
|
const tagAmounts: Record<string, number> = {};
|
||||||
memos.forEach((memo) => {
|
memos.forEach((memo) => {
|
||||||
memo.tags.forEach((tag) => {
|
const tagSet = new Set<string>();
|
||||||
if (tagAmounts[tag]) {
|
for (const tag of memo.tags) {
|
||||||
tagAmounts[tag] += 1;
|
const parts = tag.split("/");
|
||||||
} else {
|
let currentTag = "";
|
||||||
tagAmounts[tag] = 1;
|
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;
|
return tagAmounts;
|
||||||
|
Reference in New Issue
Block a user