← back to Glitterwalls
/api/facets total now reflects filtered list (respects q + aesthetic)
6337f651335f0a3afcf99d309e4821d90842944f · 2026-05-25 21:07:05 -0700 · steve
Files touched
Diff
commit 6337f651335f0a3afcf99d309e4821d90842944f
Author: steve <steve@designerwallcoverings.com>
Date: Mon May 25 21:07:05 2026 -0700
/api/facets total now reflects filtered list (respects q + aesthetic)
---
server.js | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/server.js b/server.js
index e156f16..ab94544 100644
--- a/server.js
+++ b/server.js
@@ -208,12 +208,22 @@ app.get('/api/sliders', (req, res) => {
});
app.get('/api/facets', (req, res) => {
+ const { q, aesthetic } = req.query;
+ let list = PRODUCTS_NICHE;
+ if (q) {
+ const needle = String(q).toLowerCase();
+ list = list.filter(p => (p.title || '').toLowerCase().includes(needle) || (p.tags || []).some(t => String(t).toLowerCase().includes(needle)));
+ }
+ if (aesthetic && aesthetic !== 'all') list = list.filter(p => p.aesthetic === aesthetic);
+ // total reflects the FILTERED list so client counters stay accurate after a query.
+ // Aesthetic counts come from PRODUCTS_NICHE so the facet bar always shows every
+ // available bucket (otherwise picking one bucket would hide all others).
const aesthetics = {}; const vendors = {};
for (const p of PRODUCTS_NICHE) {
aesthetics[p.aesthetic] = (aesthetics[p.aesthetic] || 0) + 1;
vendors[p.vendor] = (vendors[p.vendor] || 0) + 1;
}
- res.json({ aesthetics, vendors, total: PRODUCTS_NICHE.length });
+ res.json({ aesthetics, vendors, total: list.length });
});
app.get('/api/health', (req, res) => res.json({ status: 'ok', count: PRODUCTS_NICHE.length, dropped: DROPPED }));
← 435e64b add noreferrer to all target=_blank links
·
back to Glitterwalls
·
pre-paint hydration for density + view (no grid-column flash 18d2974 →