Pages: niche hero SETS (4 photographic heroes per niche served from /niches, thumbnail picker in the Look panel, design.hero index) + new Gaming niche

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-08 14:41:29 -05:00
parent f59b3d2771
commit 9f4c913ae6
33 changed files with 23 additions and 16 deletions
+3 -3
View File
@@ -10,7 +10,7 @@ const href = u => { const s = String(u || '').trim(); return /^https?:\/\/[^\s"'
const PALETTE_NAMES = Object.keys(S.PALETTES).concat(['ink', 'ember']);
// the three knobs a page carries, with safe fallbacks for anything stored by older code
function knobs(page) { const d = page.design || {}; return { pk: S.paletteKey(d.palette), design: S.designKey(d.design), layout: S.layoutKey(d.layout), niche: S.nicheKey(d.niche) }; }
function knobs(page) { const d = page.design || {}; return { pk: S.paletteKey(d.palette), design: S.designKey(d.design), layout: S.layoutKey(d.layout), niche: S.nicheKey(d.niche), hero: d.hero }; }
function baseCss(k) {
const P = S.PALETTES[k.pk], C = P.c, dkGround = k.design === 'dark' || k.design === 'ignition';
@@ -49,7 +49,7 @@ function ctaBtn(c, extra) { const u = href(c && c.url); const t = esc((c && c.te
const headline = (k, t) => (k.design === 'ignition' ? S.blazeHeadline(t) : esc(t || ''));
// the visual on the right of a split: the member's image, else the niche hero, else the procedural card
function sideVisual(k, c) {
const img = href(c.image) || S.nicheHero(k.niche);
const img = href(c.image) || S.nicheHero(k.niche, k.hero);
if (img) return '<div class="media"><div class="k-imgframe"><img src="' + esc(img) + '" alt="' + esc(c.imageAlt || '') + '" loading="eager"></div></div>';
return '<div class="media">' + S.visualHtml(c.headline, c.bullets && c.bullets.length ? c.bullets : c.pros, c.price) + '</div>';
}
@@ -62,7 +62,7 @@ function formArea(page, opts) {
function render(page, opts) {
opts = opts || {}; const k = knobs(page); const c = page.content || {}; const split = k.layout === 'split';
const img = href(c.image) || S.nicheHero(k.niche);
const img = href(c.image) || S.nicheHero(k.niche, k.hero);
const head = '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>' + esc(c.headline || page.title || 'Page') + '</title>'
+ '<meta name="description" content="' + esc((c.sub || '').slice(0, 160)) + '">' + (page.status !== 'published' ? '<meta name="robots" content="noindex,nofollow">' : '')
+ (img ? '<meta property="og:image" content="' + esc(img) + '">' : '') + '<meta property="og:title" content="' + esc(c.headline || page.title || '') + '"><meta property="og:description" content="' + esc((c.sub || '').slice(0, 200)) + '">'
+3 -2
View File
@@ -52,7 +52,8 @@ function designFrom(body, cur) {
const palette = body.palette != null ? style.paletteKey(body.palette) : (body.niche != null && preset ? preset.palette : style.paletteKey(cur.palette));
const design = body.design != null ? style.designKey(body.design) : (body.niche != null && preset ? preset.design : style.designKey(cur.design));
const layout = body.layout != null ? style.layoutKey(body.layout) : style.layoutKey(cur.layout || (body.niche != null && preset ? 'split' : 'stack'));
return { palette, design, layout, niche };
const hero = body.niche != null && body.niche !== cur.niche ? 0 : style.heroIndex(niche, body.hero != null ? body.hero : cur.hero);
return { palette, design, layout, niche, hero };
}
async function create(owner, body) {
if (J.db.pages.filter(p => p.owner === norm(owner)).length >= 200) return { error: 'That is a lot of pages. Remove some first.' };
@@ -68,7 +69,7 @@ async function update(owner, id, body) {
if (body.remove) { J.db.pages = J.db.pages.filter(x => x !== p); J.save(); return { ok: true, removed: true }; }
if (body.title != null) p.title = String(body.title).trim().slice(0, 100) || p.title;
if (body.type != null && TYPES.includes(body.type)) p.type = body.type;
if (body.palette != null || body.design != null || body.layout != null || body.niche != null) p.design = designFrom(body, p.design || {});
if (body.palette != null || body.design != null || body.layout != null || body.niche != null || body.hero != null) p.design = designFrom(body, p.design || {});
if (body.angle != null) p.angle = String(body.angle).slice(0, 160);
if (body.content != null) { const c = sanitizeContent(Object.assign({}, p.content, body.content), p.type); if (p.type === 'squeeze' && c.formEmbed) { const why = formrestyle.problem(c.formEmbed); if (why) return { error: why }; } p.content = c; }
if (body.status != null) { if (body.status === 'published') { if (!p.content.headline) return { error: 'Give the page a headline before publishing.' }; if (p.type !== 'squeeze' && !p.content.cta.url) return { error: 'Add the button link (where the page sends people) before publishing.' }; p.status = 'published'; } else p.status = 'draft'; }
+13 -10
View File
@@ -32,26 +32,29 @@ const DESIGNS = {
ignition: { label: 'Ignition', blurb: 'Black ground, ray burst, hot headline' },
};
const LAYOUTS = { stack: { label: 'Stacked', blurb: 'Centred copy, image below the headline' }, split: { label: 'Split hero', blurb: 'Copy left, visual right' } };
const NICHE_HERO_ORIGIN = 'https://mybrandedvoice.com';
const HERO_COUNT = { 'health-wellness': 4, 'make-money-online': 4, 'personal-finance': 4, 'coaching-consulting': 4, 'self-improvement': 4, relationships: 4, gaming: 4 }; // /niches/<key>-1..n.jpg (photographic, 1536x1024, textless)
const NICHES = {
'health-wellness': { label: 'Health & Wellness', design: 'light', palette: 'ocean', hero: '/marketing/niches/health-wellness.jpg', blurb: 'Fresh and calm: teal & sand, clean light pages' },
'make-money-online': { label: 'Make Money Online', design: 'ignition', palette: 'heritage', hero: '/marketing/niches/make-money-online.jpg', blurb: 'Launch heat: black ground, inferno orange' },
'personal-finance': { label: 'Personal Finance', design: 'dark', palette: 'midnight', hero: '/marketing/niches/personal-finance.jpg', blurb: 'Trustworthy: navy & amber, dramatic dark' },
'coaching-consulting': { label: 'Coaching & Consulting', design: 'editorial', palette: 'plum', hero: '/marketing/niches/coaching-consulting.jpg', blurb: 'Premium: magazine layout, aubergine & honey' },
'self-improvement': { label: 'Self-Improvement', design: 'light', palette: 'heritage', hero: '/marketing/niches/self-improvement.jpg', blurb: 'Uplifting: green & gold on clean white' },
relationships: { label: 'Relationships', design: 'light', palette: 'plum', hero: '/marketing/niches/relationships.jpg', blurb: 'Warm: aubergine & honey, soft light pages' },
'health-wellness': { label: 'Health & Wellness', design: 'light', palette: 'ocean', blurb: 'Fresh and calm: teal & sand, clean light pages' },
'make-money-online': { label: 'Make Money Online', design: 'ignition', palette: 'heritage', blurb: 'Launch heat: black ground, inferno orange' },
'personal-finance': { label: 'Personal Finance', design: 'dark', palette: 'midnight', blurb: 'Trustworthy: navy & amber, dramatic dark' },
'coaching-consulting': { label: 'Coaching & Consulting', design: 'editorial', palette: 'plum', blurb: 'Premium: magazine layout, aubergine & honey' },
'self-improvement': { label: 'Self-Improvement', design: 'light', palette: 'heritage', blurb: 'Uplifting: green & gold on clean white' },
relationships: { label: 'Relationships', design: 'light', palette: 'plum', blurb: 'Warm: aubergine & honey, soft light pages' },
gaming: { label: 'Gaming', design: 'dark', palette: 'midnight', blurb: 'Night mode: navy & amber, glow hero' },
};
const paletteKey = n => { n = String(n || '').toLowerCase(); return PALETTES[n] ? n : LEGACY[n] || 'graphite'; };
const designKey = n => (DESIGNS[String(n || '').toLowerCase()] ? String(n).toLowerCase() : 'dark');
const layoutKey = n => (LAYOUTS[String(n || '').toLowerCase()] ? String(n).toLowerCase() : 'stack');
const nicheKey = n => (NICHES[String(n || '').toLowerCase()] ? String(n).toLowerCase() : '');
const nicheHero = n => (NICHES[n] ? NICHE_HERO_ORIGIN + NICHES[n].hero : '');
const nicheHeroes = n => (NICHES[n] ? Array.from({ length: HERO_COUNT[n] || 1 }, (_, i) => '/niches/' + n + '-' + (i + 1) + '.jpg') : []);
const heroIndex = (n, i) => { const L = nicheHeroes(n).length; i = Number(i); return L && Number.isInteger(i) && i >= 0 && i < L ? i : 0; };
const nicheHero = (n, i) => { const h = nicheHeroes(n); return h.length ? h[heroIndex(n, i)] : ''; };
// what the editor shows: swatches, labels, blurbs
const catalog = () => ({
palettes: Object.entries(PALETTES).map(([k, p]) => ({ key: k, label: p.label, sub: p.sub, swatch: [p.c.inkGreen, p.c.gold, p.c.green] })),
designs: Object.entries(DESIGNS).map(([k, d]) => ({ key: k, label: d.label, blurb: d.blurb })),
layouts: Object.entries(LAYOUTS).map(([k, l]) => ({ key: k, label: l.label, blurb: l.blurb })),
niches: Object.entries(NICHES).map(([k, n]) => ({ key: k, label: n.label, blurb: n.blurb, design: n.design, palette: n.palette, hero: NICHE_HERO_ORIGIN + n.hero })),
niches: Object.entries(NICHES).map(([k, n]) => ({ key: k, label: n.label, blurb: n.blurb, design: n.design, palette: n.palette, hero: nicheHero(k, 0), heroes: nicheHeroes(k) })),
});
// ---- colour helpers ----
@@ -130,4 +133,4 @@ function visualHtml(offer, bullets, price) {
return '<div class="pv">' + chip + '<div class="pv-under"></div><div class="pv-card"><div class="pv-bar"><span class="pv-dot"></span><span class="pv-dot"></span><span class="pv-dot"></span></div><div class="pv-stat"><span class="pv-num">' + esc(many ? '100%' : offer) + '</span><span class="pv-lbl">' + esc(many ? offer : 'complete system') + '</span></div><div class="pv-meter"><i></i></div>' + (bullets.length ? '<div class="pv-body" style="padding-top:4px">' + ticks(bullets) + '</div>' : '') + '</div></div>';
}
module.exports = { FONT, SERIF, IGNITION_DISPLAY, PALETTES, DESIGNS, LAYOUTS, NICHES, paletteKey, designKey, layoutKey, nicheKey, nicheHero, catalog, rgba, hotRamp, blazeHeadline, kitCss, visualCss, visualHtml, esc };
module.exports = { FONT, SERIF, IGNITION_DISPLAY, PALETTES, DESIGNS, LAYOUTS, NICHES, paletteKey, designKey, layoutKey, nicheKey, nicheHero, nicheHeroes, heroIndex, catalog, rgba, hotRamp, blazeHeadline, kitCss, visualCss, visualHtml, esc };
+1
View File
@@ -49,6 +49,7 @@
// the Look panel: niche preset, design, colours, layout. Each change saves at once and the gallery/preview refresh.
const d = p.design || {}; const setLook = async patch => { try { await api('/api/my/pages/' + p.id, patch); load(true); } catch (e) { toast(e.message, true); } };
const ns = $('niche'); ns.innerHTML = '<option value="">None (set it yourself)</option>' + STYLES.niches.map(n => '<option value="' + n.key + '"' + (d.niche === n.key ? ' selected' : '') + '>' + esc(n.label) + ' \u00b7 ' + esc(n.blurb) + '</option>').join(''); ns.onchange = () => setLook({ niche: ns.value });
{ const nn = STYLES.niches.find(n => n.key === d.niche); const row = $('heroRow'); if (nn && nn.heroes && nn.heroes.length > 1 && row) { row.hidden = false; $('heroes').innerHTML = nn.heroes.map((u, i) => '<button type="button" data-h="' + i + '" class="' + ((Number(d.hero) || 0) === i ? 'on' : '') + '" title="Hero ' + (i + 1) + '"><img src="' + esc(u) + '" alt="" loading="lazy"></button>').join(''); $('heroes').querySelectorAll('button').forEach(b => b.addEventListener('click', () => setLook({ hero: Number(b.dataset.h) }))); } else if (row) row.hidden = true; }
$('designs').innerHTML = STYLES.designs.map(x => '<button type="button" data-d="' + x.key + '" class="' + (d.design === x.key ? 'on' : '') + '" title="' + esc(x.blurb) + '">' + esc(x.label) + '</button>').join('');
$('designs').querySelectorAll('button').forEach(b => b.addEventListener('click', () => setLook({ design: b.dataset.d })));
$('pal').innerHTML = STYLES.palettes.map(x => '<button type="button" data-p="' + x.key + '" class="' + (d.palette === x.key ? 'on' : '') + '" title="' + esc(x.label + ', ' + x.sub) + '">' + x.swatch.map(col => '<i style="background:' + col + '"></i>').join('') + '</button>').join('');
Binary file not shown.

After

Width:  |  Height:  |  Size: 209 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

+3 -1
View File
@@ -10,6 +10,7 @@
<style>
.look{display:grid;gap:10px;margin:6px 0 10px}.lk-row{display:flex;gap:10px;align-items:flex-start}.lk-k{flex:none;width:64px;font:700 11px var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--muted);padding-top:9px}
.lk-opts{display:flex;gap:6px;flex-wrap:wrap}.lk-opts button{font:600 12px var(--body);padding:7px 10px;border-radius:7px;border:1px solid var(--line);background:transparent;color:var(--fg);cursor:pointer}.lk-opts button.on{border-color:var(--accent);background:rgba(59,157,255,.12)}
.heroes{display:flex;gap:6px;flex-wrap:wrap}.heroes button{width:72px;height:48px;border-radius:7px;border:2px solid var(--line);padding:0;overflow:hidden;cursor:pointer;background:#000}.heroes button img{width:100%;height:100%;object-fit:cover;display:block;opacity:.8}.heroes button.on{border-color:var(--accent)}.heroes button.on img{opacity:1}
.pal{display:flex;gap:8px;flex-wrap:wrap}.pal button{width:34px;height:26px;border-radius:7px;border:2px solid transparent;cursor:pointer;padding:0;overflow:hidden;display:grid;grid-template-columns:1fr 1fr 1fr}.pal button i{display:block}.pal button.on{border-color:var(--fg)}
.ws{display:grid;grid-template-columns:minmax(0,1fr) 440px;min-height:calc(100vh - 94px)}
@@ -57,6 +58,7 @@
<div class="look" id="look">
<div class="sec">Look</div>
<label class="lbl">Niche preset<select class="field" id="niche"><option value="">None (set it yourself)</option></select></label>
<div class="lk-row" id="heroRow" hidden><span class="lk-k">Hero</span><div class="heroes" id="heroes"></div></div>
<div class="lk-row"><span class="lk-k">Design</span><div class="lk-opts" id="designs"></div></div>
<div class="lk-row"><span class="lk-k">Colours</span><div class="pal" id="pal"></div></div>
<div class="lk-row"><span class="lk-k">Layout</span><div class="lk-opts" id="layouts"></div></div>
@@ -68,6 +70,6 @@
</div>
</div>
<script src="/assets/cr-shell.js?v=20261008a"></script>
<script src="/assets/pages-screen.js?v=20261007a"></script>
<script src="/assets/pages-screen.js?v=20261008a"></script>
</body>
</html>