Skip to content

Commit

Permalink
sort tag filters
Browse files Browse the repository at this point in the history
  • Loading branch information
adriangohjw committed Jan 3, 2025
1 parent c5ab110 commit 6611f6e
Showing 1 changed file with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,27 @@ export const getTagFilters = (
}
})

return Object.entries(tagCategories).reduce((acc: Filter[], curValue) => {
const [category, values] = curValue
const items: FilterItem[] = Object.entries(values).map(
([label, count]) => ({
label,
count,
id: label,
}),
)
return Object.entries(tagCategories)
.reduce((acc: Filter[], curValue) => {
const [category, values] = curValue
const items: FilterItem[] = Object.entries(values)
.map(([label, count]) => ({
label,
count,
id: label,
}))
.sort((a, b) => a.label.localeCompare(b.label))

const filters: Filter[] = [
...acc,
{
items,
id: category,
label: category,
},
]
const filters: Filter[] = [
...acc,
{
items,
id: category,
label: category,
},
]

return filters
}, [])
return filters
}, [])
.sort((a, b) => a.label.localeCompare(b.label))
}

0 comments on commit 6611f6e

Please sign in to comment.