← back to Naturalwallcoverings
fix sort select not passed to /api/products query; facets total now niche-filtered count
27e35e3ada0229aafbe9df5172c8e8b7128d2ec6 · 2026-05-18 20:42:17 -0700 · Steve Abrams
Files touched
M public/index.htmlM server.js
Diff
commit 27e35e3ada0229aafbe9df5172c8e8b7128d2ec6
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Mon May 18 20:42:17 2026 -0700
fix sort select not passed to /api/products query; facets total now niche-filtered count
---
public/index.html | 3 ++-
server.js | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/public/index.html b/public/index.html
index fe85710..ee83417 100644
--- a/public/index.html
+++ b/public/index.html
@@ -430,7 +430,7 @@ textarea:focus-visible,
</script>
<script>
-const state = { q:'', facet:'all', page:1, pages:1, total:0, loading:false, exhausted:false };
+const state = { q:'', facet:'all', sort:'newest', page:1, pages:1, total:0, loading:false, exhausted:false };
const LABELS = {"all":"All"};
function escAttr(s) { return String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&':'&','<':'<','>':'>','"':'"',"'":''' }[c])); }
@@ -543,6 +543,7 @@ async function loadGridPage() {
const params = new URLSearchParams({ page:state.page, limit:24 });
if (state.q) params.set('q', state.q);
if (state.facet !== 'all') params.set('aesthetic', state.facet);
+ if (state.sort && state.sort !== 'newest') params.set('sort', state.sort);
let data;
try {
const r = await fetch('/api/products?' + params);
diff --git a/server.js b/server.js
index 10e888c..65516a1 100644
--- a/server.js
+++ b/server.js
@@ -170,7 +170,7 @@ app.get('/api/facets', (req, res) => {
aesthetics[p.aesthetic] = (aesthetics[p.aesthetic] || 0) + 1;
vendors[p.vendor] = (vendors[p.vendor] || 0) + 1;
}
- res.json({ aesthetics, vendors, total: PRODUCTS.length });
+ res.json({ aesthetics, vendors, total: PRODUCTS_NICHE.length });
});
app.get('/api/health', (req, res) => res.json({ status: 'ok', count: PRODUCTS_NICHE.length, dropped: DROPPED }));
← cc4a253 hero-4grid: relocate json from data/ to public/ for Express
·
back to Naturalwallcoverings
·
untrack 19 stale .bak/.pre- snapshot files; gitignore *.bak. 145c47c →