← back to Textilewallpaper
/api/facets: total now reflects filtered (q + aesthetic) list count
8628be97f8c458034cb57714985ef83ffebd1b9e · 2026-05-25 21:38:33 -0700 · Steve
Files touched
Diff
commit 8628be97f8c458034cb57714985ef83ffebd1b9e
Author: Steve <steve@designerwallcoverings.com>
Date: Mon May 25 21:38:33 2026 -0700
/api/facets: total now reflects filtered (q + aesthetic) list count
---
server.js | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/server.js b/server.js
index cfb3427..6a49c1f 100644
--- a/server.js
+++ b/server.js
@@ -191,12 +191,21 @@ 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 => t.toLowerCase().includes(needle)));
+ }
+ if (aesthetic && aesthetic !== 'all') list = list.filter(p => p.aesthetic === aesthetic);
+ // Aesthetic facet counts always reflect the FULL niche set so the filter rail
+ // stays useful as users navigate; `total` reflects the filtered list count.
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 }));
← a3048bd sort + density wired with localStorage pre-load hydration (n
·
back to Textilewallpaper
·
add clean-URL routes (/care, /sourcing, /trade, /history) fo 3897592 →