[object Object]

← back to Micawallpaper

fix sort: loadGridPage now passes state.sort to /api/products query

05d51a95018cc748cf132afe2ea0318c796d3c3d · 2026-05-18 20:46:11 -0700 · Steve Abrams

Files touched

Diff

commit 05d51a95018cc748cf132afe2ea0318c796d3c3d
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Mon May 18 20:46:11 2026 -0700

    fix sort: loadGridPage now passes state.sort to /api/products query
---
 public/index.html | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/public/index.html b/public/index.html
index 18e97aa..59eb62e 100644
--- a/public/index.html
+++ b/public/index.html
@@ -427,7 +427,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 => ({ '&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;' }[c])); }
@@ -540,6 +540,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) params.set('sort', state.sort);
   let data;
   try {
     const r = await fetch('/api/products?' + params);

← 0f193ca hero-4grid: relocate json from data/ to public/ for Express  ·  back to Micawallpaper  ·  fix /api/facets total to use niche-filtered count not pre-ni 52896e9 →