// Custom preview template for Sveltia CMS: mirrors the site's // Site.astro layout so the preview pane shows what the published page // will look like (hero banner, pilot banner, cards, price checklist, // journey, capability checklist), instead of Sveltia's generic field dump. // // Runs in the browser as-is: the CMS bundle exposes the globals `CMS` // and `html` (HTM, bound to the CMS's React copy). Markup elements can // carry data-key-path so click-to-highlight keeps working — clicking // a section in the preview focuses that field in the edit pane. const css = ` :root { --ink:#16213a; --muted:#5b6478; --accent:#3a55d9; --accent-soft:#eef1fd; --line:#e3e7f2; --bg:#fbfcfe; } * { box-sizing:border-box; } body { margin:0; font-family:ui-sans-serif,system-ui,-apple-system,'Segoe UI',sans-serif; color:var(--ink); background:var(--bg); line-height:1.65; } .pv-nav { display:flex; gap:0.75rem; align-items:center; padding:0.9rem 1.5rem; border-bottom:1px solid var(--line); background:#fff; color:var(--muted); font-size:0.85rem; } .pv-nav strong { color:var(--ink); display:flex; gap:0.45rem; align-items:center; } main { max-width:58rem; margin:0 auto; padding:0 1.25rem 3rem; } .pv-hero { position:relative; overflow:hidden; margin:0 -1.25rem; padding:3rem 1.25rem 2.6rem; background:radial-gradient(42rem 20rem at 85% -10%, rgba(135,87,216,0.12), transparent 60%), linear-gradient(180deg, var(--accent-soft), var(--bg)); border-bottom:1px solid var(--line); } .pv-hero h1 { font-size:2.2rem; line-height:1.15; margin:0 0 1rem; letter-spacing:-0.02em; max-width:42rem; } .pv-hero p { font-size:1.1rem; color:var(--muted); max-width:42rem; margin:0; } .pv-cta { margin-top:1.4rem; display:flex; gap:0.6rem; flex-wrap:wrap; } .pv-cta span { background:var(--accent); color:#fff; border-radius:0.5rem; padding:0.55rem 1rem; font-weight:600; font-size:0.95rem; } .pv-cta span.sec { background:#fff; color:var(--accent); border:1px solid var(--accent); } h2 { font-size:1.35rem; margin:2.2rem 0 0.8rem; letter-spacing:-0.01em; } .pv-cards { margin-top:1rem; display:grid; gap:1rem; grid-template-columns:repeat(auto-fit,minmax(14rem,1fr)); } .pv-card { background:#fff; border:1px solid var(--line); border-radius:0.7rem; padding:1rem 1.1rem; } .pv-card strong { display:block; margin-bottom:0.4rem; } .pv-card small { color:var(--muted); font-size:0.93rem; line-height:1.5; } .pv-card .pv-link { display:inline-block; margin-top:0.6rem; color:var(--accent); font-size:0.9rem; font-weight:600; } .pv-pilot { margin:1.4rem 0 0; padding:0.8rem 1.1rem; background:var(--accent); color:#fff; border-radius:0.55rem; } .pv-pilot strong { text-transform:uppercase; letter-spacing:0.06em; font-size:0.75rem; } .pv-pilot p { margin:0.2rem 0 0; font-size:0.95rem; } .pv-price { display:flex; gap:0.6rem; align-items:center; background:#fff; border:1px solid var(--line); border-radius:0.45rem; padding:0.45rem 0.6rem; margin-bottom:0.35rem; } .pv-price .tick { width:0.95rem; height:0.95rem; border:2px solid var(--accent); border-radius:50%; flex:none; } .pv-price strong { font-size:0.95rem; } fieldset.pv-pricegroup, .pv-pricegroup { border:0; margin:1.1rem 0 0; padding:0; } .pv-pricegroup legend { font-weight:600; font-size:1rem; margin-bottom:0.4rem; color:var(--ink); } .pv-modelq { font-weight:600; margin:1.4rem 0 0.4rem; } .pv-models { display:flex; gap:0.5rem; flex-wrap:wrap; } .pv-journey ol { list-style:none; padding:0; margin:0.5rem 0 0; display:grid; gap:0.55rem; } .pv-journey li { padding:0.55rem 0.9rem; background:#fff; border:1px solid var(--line); border-inline-start:3px solid var(--accent); border-radius:0.45rem; color:var(--muted); font-size:0.95rem; } .pv-journey li b { color:var(--ink); } .pv-cap { display:flex; gap:0.8rem; align-items:flex-start; background:var(--accent-soft); border:1px solid var(--line); border-radius:0.7rem; padding:0.85rem 1rem; margin-bottom:0.6rem; } .pv-cap .tick { width:1.05rem; height:1.05rem; border:2px solid var(--accent); border-radius:0.3rem; flex:none; margin-top:0.2rem; } .pv-cap strong { display:block; } .pv-cap small { color:var(--muted); } .pv-request { display:inline-block; background:var(--accent); color:#fff; border-radius:0.5rem; padding:0.55rem 1rem; font-weight:600; font-size:0.95rem; margin-top:0.6rem; } .pv-body { margin-top:1.6rem; } .pv-body h1, .pv-body h2, .pv-body h3 { margin-top:1.5rem; } .pv-body img { max-width:100%; height:auto; border-radius:0.5rem; } .pv-body ul { padding-inline-start:1.5rem; } .pv-body blockquote { margin:1.2rem 0; padding:0.4rem 1rem; border-inline-start:3px solid var(--accent); color:var(--muted); } .pv-empty { color:var(--muted); font-size:0.9rem; padding:1rem; text-align:center; } `; const items = (widgets) => (Array.isArray(widgets) ? widgets : []).map((w) => w.getIn(["data"])); const PagePreview = ({ entry, widgetFor, widgetsFor }) => { const d = (key) => entry.getIn(["data", key]); const valueProps = items(widgetsFor("value_props")); const journey = items(widgetsFor("journey")); const caps = items(widgetsFor("capabilities")); const priceGroups = items(widgetsFor("price_groups")); const priceModels = items(widgetsFor("price_models")); const hasHero = d("hero_headline") || d("hero_sub"); return html`
Validation Lab — preview
${hasHero && html`

${d("hero_headline")}

${d("hero_sub") && html`

${d("hero_sub")}

`} ${(d("cta_founders") || d("cta_hubs")) && html`

${d("cta_founders") && html`${d("cta_founders")}`} ${d("cta_hubs") && html`${d("cta_hubs")}`}

`}
`} ${d("pilot_text") && html``} ${valueProps.length > 0 && html`

${d("value_props_title") || "Cards"}

${valueProps.map((v, i) => html`
${v.get("heading")} ${v.get("text")} ${v.get("link") && html`→`}
`, )}
`} ${(priceGroups.length > 0 && priceModels.length > 0) && html`

${d("price_title")}

${d("price_note") && html`

${d("price_note")}

`}

${d("price_model_question")}

${priceModels.map((m, i) => html` ${m.get("label")} `, )}
${priceGroups.map((g, i) => { const firstModel = priceModels[0]; const opts = firstModel ? Array.from(firstModel.get("options") || []) : []; return html`
${g.get("heading")} ${opts.map((o, j) => html` ${o.get("label")} `, )}
`; })}
`} ${journey.length > 0 && html`

${d("journey_title") || "The journey"}

${d("journey_note") && html`

${d("journey_note")}

`}
    ${journey.map((s, i) => html`
  1. ${s.get("title")}${s.get("text") ? html` — ${s.get("text")}` : null}
  2. `, )}
`} ${caps.length > 0 && html`

${d("capabilities_title")}

${d("capabilities_note") && html`

${d("capabilities_note")}

`} ${caps.map((c, i) => html`
${c.get("heading")} ${c.get("text")}
`, )} ${d("capabilities_cta") && html`${d("capabilities_cta")}`}
`}
${widgetFor("body")}
${(!hasHero && valueProps.length === 0 && journey.length === 0 && caps.length === 0 && priceGroups.length === 0 && priceModels.length === 0 && !d("pilot_text")) && html`

No structured sections — the preview shows the body only.

`}
`; }; CMS.registerPreviewStyle(css, { raw: true }); CMS.registerPreviewTemplate("pages", PagePreview);