// LinkSpin page renderer (2026-09-29, restyled 2026-10-07 on the Branded Voice design system: palette x design x // layout + niche presets, see pagestyle.js). Bridge, review and squeeze pages as standalone HTML. Everything the // member typed is escaped; the only form on a page is either our own capture form or a provider form rebuilt by // formrestyle (parse-or-refuse). No inline script: tracking lives in /assets/pt.js so the page can carry a real CSP. 'use strict'; const formrestyle = require('./formrestyle'); const S = require('./pagestyle'); const esc = S.esc; const href = u => { const s = String(u || '').trim(); return /^https?:\/\/[^\s"'<>]+$/i.test(s) && s.length <= 700 ? 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), hero: d.hero }; } function baseCss(k) { const P = S.PALETTES[k.pk], C = P.c, dkGround = k.design === 'dark' || k.design === 'ignition'; const ground = k.design === 'editorial' ? C.cream : k.design === 'ignition' ? '#060606' : k.design === 'light' ? '#fff' : C.inkGreen; const bodyInk = k.design === 'editorial' ? C.body : k.design === 'ignition' ? S.rgba(C.cream, 0.85) : k.design === 'light' ? C.body : S.rgba(C.cream, 0.82); const font = k.design === 'editorial' ? '18px/1.7 ' + S.SERIF : '17px/1.6 ' + S.FONT; const heroSkin = k.design === 'light' ? 'background:radial-gradient(ellipse 800px 480px at 85% 0%,' + S.rgba(C.gold, 0.1) + ',transparent 60%),radial-gradient(ellipse 700px 500px at 0% 100%,' + S.rgba(C.green, 0.08) + ',transparent 60%),#fff;color:' + C.ink : k.design === 'editorial' ? 'background:' + C.cream + ';color:' + C.ink + ';border-bottom:2px solid ' + C.ink : k.design === 'ignition' ? 'background:transparent;color:' + C.cream : 'background:radial-gradient(ellipse 900px 500px at 70% -10%,' + S.rgba(C.gold, 0.16) + ',transparent 60%),radial-gradient(ellipse 700px 480px at 12% 8%,' + S.rgba(C.green, 0.35) + ',transparent 65%),' + C.inkGreen + ';color:' + C.cream; const heroInk = dkGround ? C.cream : C.ink, heroBody = dkGround ? S.rgba(C.cream, 0.72) : C.body; const h1font = k.design === 'ignition' ? 'font-family:' + S.IGNITION_DISPLAY + ';font-weight:400;text-transform:uppercase;letter-spacing:.5px;line-height:.98;font-size:clamp(40px,7vw,72px)' : k.design === 'editorial' ? 'font-family:' + S.SERIF + ';font-weight:700;font-size:clamp(34px,5.6vw,54px);line-height:1.08;letter-spacing:-.01em' : 'font-weight:800;font-size:clamp(32px,5.6vw,52px);line-height:1.08;letter-spacing:-.028em'; return '*{box-sizing:border-box}body{margin:0;background:' + ground + ';color:' + bodyInk + ';font:' + font + ';-webkit-font-smoothing:antialiased}a{color:' + (dkGround ? C.goldSoft : C.green) + '}p{margin:0 0 16px}' + '.hero,main,.foot,.wrap{position:relative;z-index:1}' + '.hero{' + heroSkin + ';padding:72px 24px 64px;text-align:center;overflow:hidden}.hero>*{position:relative;z-index:1}' + '.hero h1{' + h1font + ';margin:0 auto 18px;max-width:840px;color:' + heroInk + ';text-wrap:balance}.hero .lead{font-size:19px;line-height:1.6;color:' + heroBody + ';max-width:660px;margin:0 auto 8px}.hero .media{max-width:760px;margin:34px auto 0}.hero .ctawrap{margin:28px 0 0}' + '.hs-grid{display:grid;grid-template-columns:1.1fr .9fr;gap:56px;align-items:center;max-width:1080px;margin:0 auto;text-align:left}.hero.split{text-align:left;padding:72px 32px 64px}.hero.split h1{margin:0 0 18px;text-align:left;max-width:none}.hero.split .lead{margin:0 0 8px;max-width:none}.hero.split .media{margin:0}' + 'main{max-width:680px;margin:0 auto;padding:56px 24px 64px}main h2{font-size:' + (k.design === 'editorial' ? '28px;font-family:' + S.SERIF : '24px') + ';margin:28px 0 10px;color:' + (dkGround ? C.cream : C.ink) + '}main h3{font-size:18px;margin:18px 0 6px;color:' + (dkGround ? C.cream : C.ink) + '}' + (k.design === 'editorial' ? 'main p:first-of-type::first-letter{float:left;font-size:58px;line-height:.9;padding:6px 10px 0 0;color:' + C.gold + ';font-weight:700}' : '') // squeeze card + '.wrap{min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:32px 20px 0}' + '.card{background:' + (k.design === 'ignition' ? 'rgba(8,8,8,.55)' : '#fff') + ';max-width:560px;width:100%;border-radius:12px;border-top:4px solid ' + C.gold + ';padding:44px 40px 40px;text-align:center;box-shadow:0 24px 80px rgba(0,0,0,' + (dkGround ? '.45' : '.12') + ');color:' + (k.design === 'ignition' ? S.rgba(C.cream, 0.85) : C.body) + (k.design === 'ignition' ? ';border:1px solid ' + S.rgba(S.hotRamp(k.pk).hot1, 0.3) + ';border-top:4px solid ' + S.hotRamp(k.pk).hot1 + ';backdrop-filter:blur(6px)' : '') + '}' + '.card h1{' + h1font.replace(/clamp\([^)]*\)/, 'clamp(28px,5.5vw,38px)') + ';margin:0 0 16px;color:' + (k.design === 'ignition' ? '#fff' : C.ink) + '}.card .sub{font-size:18px;line-height:1.6;margin:0 0 24px}.card ul.checks{margin:0 auto 24px;max-width:26em}.card .hero-img{width:100%;height:auto;border-radius:12px;margin:0 0 20px}' + '.sq-grid{display:grid;grid-template-columns:1fr .85fr;gap:56px;align-items:center;max-width:1060px;width:100%;margin:0 auto}.sq-grid .card{max-width:none;text-align:left}.sq-grid ul.checks{max-width:none;margin:0 0 24px}' + '@media(max-width:820px){.hs-grid,.sq-grid{grid-template-columns:1fr;gap:36px}.hero.split{text-align:center}.hero.split h1{text-align:center}.sq-grid .card{text-align:center}.sq-grid .pv,.hs-grid .media{order:-1}}@media(max-width:480px){.card{padding:32px 20px 28px}.hero{padding:52px 18px 44px}}' + S.kitCss(k.design, k.pk) + S.visualCss(k.pk) + (dkGround ? '.pc div{background:rgba(255,255,255,.04);border-color:' + S.rgba(C.cream, 0.1) + ';color:' + S.rgba(C.cream, 0.85) + '}.verdict{background:rgba(255,255,255,.04);color:' + S.rgba(C.cream, 0.85) + '}.bonus{background:rgba(255,255,255,.04);border-color:' + S.rgba(C.cream, 0.12) + ';box-shadow:none;color:' + S.rgba(C.cream, 0.85) + '}.bonus .tag{background:' + S.rgba(C.gold, 0.16) + ';color:' + C.goldSoft + '}' : '') + (k.design === 'editorial' ? '.foot{color:' + C.muted + '}' : dkGround ? '.foot{color:rgba(245,241,232,.5)}' : '.foot{color:' + C.muted + '}'); } const paras = t => String(t || '').split(/\n\s*\n/).map(x => x.trim()).filter(Boolean).map(x => '

' + esc(x).replace(/\n/g, '
') + '

').join(''); const checks = arr => (arr || []).filter(Boolean).length ? '' : ''; function stars(n) { const k = Math.max(0, Math.min(5, Math.round(Number(n) || 0))); return '
' + '★'.repeat(k) + '☆'.repeat(5 - k) + '
'; } const eyebrow = t => t ? '
' + esc(t) + '
' : ''; function ctaBtn(c, extra) { const u = href(c && c.url); const t = esc((c && c.text) || 'Continue'); return u ? '
' + '' + t + '' + (extra || '') + '
' : ''; } 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, k.hero); if (img) return '
' + esc(c.imageAlt || '') + '
'; return '
' + S.visualHtml(c.headline, c.bullets && c.bullets.length ? c.bullets : c.pros, c.price) + '
'; } function formArea(page, opts) { const c = page.content || {}; if (c.formEmbed) { const parsed = formrestyle.parse(c.formEmbed); if (parsed) return '
' + formrestyle.html(parsed, (c.cta && c.cta.text) || 'Send me the details') + '
'; } return '
' + '
'; } 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, k.hero); const head = '' + esc(c.headline || page.title || 'Page') + '' + '' + (page.status !== 'published' ? '' : '') + (img ? '' : '') + '' + ''; let body = ''; if (page.type === 'squeeze') { const card = '
' + eyebrow(c.eyebrow || 'Free · Instant access') + '

' + headline(k, c.headline) + '

' + (c.sub ? '

' + esc(c.sub) + '

' : '') + (!split && img ? '' + esc(c.imageAlt || '') + '' : '') + checks(c.bullets) + formArea(page, opts) + (c.privacy ? '

' + esc(c.privacy) + '

' : '

No spam. Unsubscribe any time.

') + '
'; body = '
' + (split ? '
' + card + sideVisual(k, c) + '
' : card.replace('
', '
')) + '
'; } else { const isReview = page.type === 'review'; const heroCopy = eyebrow(c.eyebrow || (isReview ? 'Review' : '')) + '

' + headline(k, c.headline) + '

' + (isReview && c.rating ? stars(c.rating) : '') + (c.sub ? '

' + esc(c.sub) + '

' : '') + ctaBtn(c.cta); const media = img ? '
' + esc(c.imageAlt || '') + '
' : (split ? sideVisual(k, c) : ''); const hero = split ? '
' + heroCopy + '
' + media + '
' : '
' + heroCopy + media + '
'; let main = paras(c.body); if (isReview) { main += ((c.pros && c.pros.length) || (c.cons && c.cons.length) ? '

What works

What to know

' : '') + (c.verdict ? '
Verdict. ' + esc(c.verdict) + '
' : ''); } else { main += checks(c.bullets) + (c.bonus ? '
' + esc(c.bonusTitle || 'Bonus when you join through this page') + '
' + paras(c.bonus) + '
' : ''); } main += ctaBtn(c.cta); body = hero + '
' + main + '
'; } const foot = '
' + esc(c.disclaimer || 'Results depend on effort. Nothing here is a promise of income.') + (opts.footerLink ? ' · ' + esc(opts.footerText || 'Made with LinkSpin') + '' : '') + '
'; return head + body + foot + ''; } module.exports = { render, PALETTE_NAMES, knobs, catalog: S.catalog };