feat(boards list): add filter by tag

This commit is contained in:
Tom (plebeius.eth)
2025-02-03 22:12:00 +01:00
parent cf849bab70
commit 0716aac9e2
7 changed files with 64 additions and 23 deletions
+17
View File
@@ -0,0 +1,17 @@
import { useMemo } from 'react';
// Add this helper function to collect unique tags from subplebbits
const getUniqueTags = (multisub: any) => {
const allTags = new Set<string>();
Object.values(multisub).forEach((sub: any) => {
if (sub?.tags?.length) {
sub.tags.forEach((tag: string) => allTags.add(tag));
}
});
return Array.from(allTags).sort();
};
// Export tags as a derived value where it's needed
export const useDefaultSubplebbitTags = (subplebbits: any) => {
return useMemo(() => getUniqueTags(subplebbits), [subplebbits]);
};