← back to Madagascarwallpaper
/api/facets now honors q/aesthetic/vendor filters — total reflects filtered list
a8b0e7f9e4541e8c16e348631dbbae62667b1648 · 2026-05-25 21:16:51 -0700 · Steve
Files touched
Diff
commit a8b0e7f9e4541e8c16e348631dbbae62667b1648
Author: Steve <steve@designerwallcoverings.com>
Date: Mon May 25 21:16:51 2026 -0700
/api/facets now honors q/aesthetic/vendor filters — total reflects filtered list
---
server.js | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/server.js b/server.js
index 945f29f..94e33d5 100644
--- a/server.js
+++ b/server.js
@@ -198,12 +198,22 @@ app.get('/api/sliders', (req, res) => {
});
app.get('/api/facets', (req, res) => {
+ // Reflect the active filters so the badge above the grid shows the FILTERED
+ // count (matching what /api/products returns), not the global total.
+ const { q, aesthetic, vendor } = 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);
+ if (vendor && vendor !== 'all') list = list.filter(p => p.vendor === vendor);
const aesthetics = {}; const vendors = {};
- for (const p of PRODUCTS_NICHE) {
+ for (const p of list) {
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 }));
← 6bb55e3 wire api-vendor-redact middleware as first app.use — strips
·
back to Madagascarwallpaper
·
remove p.vendor render on rail cards — replace with 'Designe 7955e28 →