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:
@@ -15,8 +15,17 @@ const categories = computed(() => {
|
|||||||
return Array.from(cats).sort()
|
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(() => {
|
const filtered = computed(() => {
|
||||||
if (!activeCategory.value) return products.value
|
if (!activeCategory.value) return onePerCategory.value
|
||||||
return products.value.filter((p) => p.category === activeCategory.value)
|
return products.value.filter((p) => p.category === activeCategory.value)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user