fix: show one product per category on home (4 total)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-17 02:15:05 +00:00
parent 7dab35f896
commit fafe357329

View File

@@ -15,8 +15,17 @@ const categories = computed(() => {
return Array.from(cats).sort()
})
const onePerCategory = computed(() => {
const seen = new Set<string>()
return products.value.filter((p) => {
if (seen.has(p.category)) return false
seen.add(p.category)
return true
})
})
const filtered = computed(() => {
if (!activeCategory.value) return products.value
if (!activeCategory.value) return onePerCategory.value
return products.value.filter((p) => p.category === activeCategory.value)
})