Fix Tag Filtering

This commit is contained in:
Stefan Hardegger
2025-07-25 07:49:07 +02:00
parent 12a8f2ee27
commit 6f478ab97a
4 changed files with 55 additions and 12 deletions

View File

@@ -11,15 +11,17 @@ interface TagFilterProps {
export default function TagFilter({ tags, selectedTags, onTagToggle }: TagFilterProps) {
if (!Array.isArray(tags) || tags.length === 0) return null;
// Sort tags by usage count (descending) and then alphabetically
const sortedTags = [...tags].sort((a, b) => {
const aCount = a.storyCount || 0;
const bCount = b.storyCount || 0;
if (bCount !== aCount) {
return bCount - aCount;
}
return a.name.localeCompare(b.name);
});
// Filter out tags with no stories, then sort by usage count (descending) and then alphabetically
const sortedTags = [...tags]
.filter(tag => (tag.storyCount || 0) > 0)
.sort((a, b) => {
const aCount = a.storyCount || 0;
const bCount = b.storyCount || 0;
if (bCount !== aCount) {
return bCount - aCount;
}
return a.name.localeCompare(b.name);
});
return (
<div className="space-y-2">