[object Object]

← back to Silverleafwallpaper

rails: build from tags via shared rail-match helper (fix degenerate single-rail collapse)

e16b18cc7b1596c12f858e7987dd02fe9c9ffaa9 · 2026-05-26 10:18:00 -0700 · Steve Abrams

- Add require('../_shared/rail-match') for buildRails/railFacets
- /api/sliders: use buildRails(PRODUCTS_NICHE, SITE_RAILS) — tags-aware, multi-membership
- /api/facets aesthetics: use railFacets() — consistent with sliders
- site.config.json rails[]: replace aesthetic-only buckets (silver/antique/chrome) with
  tag-frequency-driven buckets: contemporary(62%), vinyl(60%), gray(59%), geometric(26%),
  textured(59%), modern(25%) — all clear 8% threshold, none vendor names

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files touched

Diff

commit e16b18cc7b1596c12f858e7987dd02fe9c9ffaa9
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Tue May 26 10:18:00 2026 -0700

    rails: build from tags via shared rail-match helper (fix degenerate single-rail collapse)
    
    - Add require('../_shared/rail-match') for buildRails/railFacets
    - /api/sliders: use buildRails(PRODUCTS_NICHE, SITE_RAILS) — tags-aware, multi-membership
    - /api/facets aesthetics: use railFacets() — consistent with sliders
    - site.config.json rails[]: replace aesthetic-only buckets (silver/antique/chrome) with
      tag-frequency-driven buckets: contemporary(62%), vinyl(60%), gray(59%), geometric(26%),
      textured(59%), modern(25%) — all clear 8% threshold, none vendor names
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---
 package-lock.json | 13 +++++++++++++
 server.js         | 12 ++++--------
 site.config.json  | 12 ++++++------
 3 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index 1d90b97..b239f90 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8,6 +8,7 @@
       "name": "silverleafwallpaper",
       "version": "0.1.0",
       "dependencies": {
+        "dotenv": "^17.4.2",
         "express": "^4.21.0",
         "helmet": "^8.1.0"
       }
@@ -172,6 +173,18 @@
         "npm": "1.2.8000 || >= 1.4.16"
       }
     },
+    "node_modules/dotenv": {
+      "version": "17.4.2",
+      "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.4.2.tgz",
+      "integrity": "sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==",
+      "license": "BSD-2-Clause",
+      "engines": {
+        "node": ">=12"
+      },
+      "funding": {
+        "url": "https://dotenvx.com"
+      }
+    },
     "node_modules/dunder-proto": {
       "version": "1.0.1",
       "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
diff --git a/server.js b/server.js
index d1bf189..fb705e8 100644
--- a/server.js
+++ b/server.js
@@ -20,6 +20,7 @@ if (ADMIN_ENABLED) {
   try { catalog = require('../_shared/admin-catalog'); }
   catch (e) { console.error(`[${__SITE}] admin-catalog unavailable (${e.message}) — falling back to static JSON`); }
 }
+const { buildRails, railFacets } = require('../_shared/rail-match');
 const siteCfg = JSON.parse(fs.readFileSync(path.join(__dirname, 'site.config.json'), 'utf8'));
 const SITE_SLUG = siteCfg.slug || __SITE;
 const SITE_RAILS = Array.isArray(siteCfg.rails) ? siteCfg.rails : [];
@@ -169,12 +170,7 @@ app.get('/api/products', (req, res) => {
 });
 
 app.get('/api/sliders', (req, res) => {
-  const out = [];
-  for (const a of SITE_RAILS) {
-    const items = PRODUCTS_NICHE.filter(p => p.aesthetic === a).slice(0, 12);
-    if (items.length >= 4) out.push({ aesthetic: a, items });
-  }
-  res.json({ rails: out });
+  res.json({ rails: buildRails(PRODUCTS_NICHE, SITE_RAILS) });
 });
 
 app.get('/api/facets', (req, res) => {
@@ -188,9 +184,9 @@ app.get('/api/facets', (req, res) => {
   }
   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 = {};
+  const aesthetics = railFacets(list, SITE_RAILS);
+  const vendors = {};
   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: list.length });
diff --git a/site.config.json b/site.config.json
index 1fabd7c..6ab4bac 100644
--- a/site.config.json
+++ b/site.config.json
@@ -10,12 +10,12 @@
     "accent": "#c8c8d4"
   },
   "rails": [
-    "silver",
-    "antique",
-    "tarnished",
-    "platinum",
-    "chrome",
-    "iridescent"
+    "contemporary",
+    "vinyl",
+    "gray",
+    "geometric",
+    "textured",
+    "modern"
   ],
   "port": 9912
 }

← 039c059 rails: editorial labels for firing aesthetic buckets  ·  back to Silverleafwallpaper  ·  rails: editorial labels for new tag-derived rail keys (index ca347e1 →