← back to Healthcarewallpaper
/api/facets drill-down counts over active filtered set + clean-URL routes for /care|history|sourcing|trade|vocabulary (301 from .html, serve clean) + sitemap lists them
72354645783bda5e991140183cdac9b988ee1a87 · 2026-06-01 07:31:18 -0700 · Steve
Files touched
Diff
commit 72354645783bda5e991140183cdac9b988ee1a87
Author: Steve <steve@designerwallcoverings.com>
Date: Mon Jun 1 07:31:18 2026 -0700
/api/facets drill-down counts over active filtered set + clean-URL routes for /care|history|sourcing|trade|vocabulary (301 from .html, serve clean) + sitemap lists them
---
server.js | 42 ++++++++++++++++++++++++++++++++----------
1 file changed, 32 insertions(+), 10 deletions(-)
diff --git a/server.js b/server.js
index 266aa8d..d7cb515 100644
--- a/server.js
+++ b/server.js
@@ -159,17 +159,36 @@ app.use((req, res, next) => {
require('./_universal-contact')(app, { siteName: "Healthcare Wallpaper", zdColor: "#80c8b8", zdPosition: 'right' });
require('./_universal-auth')(app, { siteName: "healthcarewallpaper" });
+// Clean-URL routes — serve /care (not /care.html) and 301 the legacy .html
+// form to the clean URL. Mounted BEFORE express.static so /care.html never
+// serves directly. The page nav links already point at clean URLs which would
+// otherwise 404 (no route served them). Loop fix-pass 2026-06-01.
+const CLEAN_PAGES = ['care', 'history', 'sourcing', 'trade', 'vocabulary'];
+for (const pg of CLEAN_PAGES) {
+ app.get('/' + pg + '.html', (req, res) => res.redirect(301, '/' + pg));
+ app.get('/' + pg, (req, res) => res.sendFile(path.join(__dirname, 'public', pg + '.html')));
+}
+// Legacy /index.html -> / (canonical)
+app.get('/index.html', (req, res) => res.redirect(301, '/'));
+
app.use(express.static(path.join(__dirname, 'public')));
-app.get('/api/products', (req, res) => {
- const { q, aesthetic, vendor, page = 1, limit = 24, sort = 'newest'} = req.query;
+// Shared filter — applies q/aesthetic/vendor to PRODUCTS_NICHE. `skip` lets a
+// facet count over the set filtered by the OTHER active facets (drill-down).
+function filterProducts({ q, aesthetic, vendor } = {}, skip) {
let list = PRODUCTS_NICHE;
- if (q) {
- const needle = q.toLowerCase();
+ if (q && skip !== '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 => productInRail(p, aesthetic));
- if (vendor && vendor !== 'all') list = list.filter(p => p.vendor === vendor);
+ if (aesthetic && aesthetic !== 'all' && skip !== 'aesthetic') list = list.filter(p => productInRail(p, aesthetic));
+ if (vendor && vendor !== 'all' && skip !== 'vendor') list = list.filter(p => p.vendor === vendor);
+ return list;
+}
+
+app.get('/api/products', (req, res) => {
+ const { q, aesthetic, vendor, page = 1, limit = 24, sort = 'newest'} = req.query;
+ let list = filterProducts({ q, aesthetic, vendor });
list = sortProducts(list, sort);
const total = list.length;
const pageNum = Math.max(1, parseInt(page) || 1);
@@ -184,12 +203,15 @@ app.get('/api/sliders', (req, res) => {
});
app.get('/api/facets', (req, res) => {
- const aesthetics = railFacets(PRODUCTS_NICHE, SITE_RAILS);
+ const { q, aesthetic, vendor } = req.query;
+ // Each dimension counts over the set filtered by the OTHER active facets
+ // (drill-down), not the whole niche catalog. total = fully-filtered count.
+ const aesthetics = railFacets(filterProducts({ q, aesthetic, vendor }, 'aesthetic'), SITE_RAILS);
const vendors = {};
- for (const p of PRODUCTS_NICHE) {
+ for (const p of filterProducts({ q, aesthetic, vendor }, 'vendor')) {
vendors[p.vendor] = (vendors[p.vendor] || 0) + 1;
}
- res.json({ aesthetics, vendors, total: PRODUCTS_NICHE.length });
+ res.json({ aesthetics, vendors, total: filterProducts({ q, aesthetic, vendor }).length });
});
app.get('/api/health', (req, res) => res.json({ status: 'ok', count: PRODUCTS_NICHE.length, dropped: DROPPED }));
@@ -211,7 +233,7 @@ Sitemap: https://healthcarewallpaper.com/sitemap.xml
`);
});
app.get('/sitemap.xml', (req, res) => {
- const urls = ['/'];
+ const urls = ['/', ...CLEAN_PAGES.map(p => '/' + p)];
const xml = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${urls.map(u => ` <url><loc>https://healthcarewallpaper.com${u}</loc><changefreq>weekly</changefreq></url>`).join('\n')}
← 4c64d72 scrub residual 3rd-party vendor names from products.json sou
·
back to Healthcarewallpaper
·
noopener,noreferrer on sister-site window.open popup 5ddda85 →