← back to Silkwallpaper
/api/facets total + counts respect q/aesthetic filters
e11ce0d5226f2008e68284d395b7e5fab1d32113 · 2026-05-25 21:35:55 -0700 · Steve Abrams
Files touched
Diff
commit e11ce0d5226f2008e68284d395b7e5fab1d32113
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Mon May 25 21:35:55 2026 -0700
/api/facets total + counts respect q/aesthetic filters
---
server.js | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/server.js b/server.js
index 72fb683..8b8f9aa 100644
--- a/server.js
+++ b/server.js
@@ -183,12 +183,22 @@ app.get('/api/sliders', (req, res) => {
});
app.get('/api/facets', (req, res) => {
+ // Counts + total reflect the FILTERED list (same q/aesthetic the grid is
+ // showing) — otherwise the chips lie and "X patterns" mismatches the grid.
+ const q = (req.query.q || '').toLowerCase().trim();
+ const aesthetic = (req.query.aesthetic || '').trim();
+ let filtered = PRODUCTS_NICHE;
+ if (q) filtered = filtered.filter(p =>
+ (p.title || '').toLowerCase().includes(q) ||
+ (p.tags || []).some(t => String(t).toLowerCase().includes(q))
+ );
+ if (aesthetic && aesthetic !== 'all') filtered = filtered.filter(p => p.aesthetic === aesthetic);
const aesthetics = {}; const vendors = {};
- for (const p of PRODUCTS_NICHE) {
+ for (const p of filtered) {
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: filtered.length });
});
app.get('/api/health', (req, res) => res.json({ status: 'ok', count: PRODUCTS_NICHE.length, dropped: DROPPED }));
← 3bb8b98 add clean-URL routes for history/vocabulary/sourcing/care/tr
·
back to Silkwallpaper
·
remove p.vendor render on rails + add noreferrer to facebook 49000cf →