Phase 5 part 3: build pages from a site's own sections

Sites → New pages: the AI composes a landing, product, alternative,
comparison or blog page as the site's own sections, from the profile and
optionally a product, competitor, buying signal or SEO brief. Code checks
every section type, warns on unknown fields and missing pages, tags a
signal's links with its campaign and finds experience claims. Pages are
edited here, pushed to their own branch with a preview, and opened as pull
requests after the claims are confirmed. Schema 22.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 14:12:57 -07:00
co-authored by Claude Opus 5.5
parent 233c6ac630
commit 11b80b6461
15 changed files with 1737 additions and 1 deletions
+13
View File
@@ -62,6 +62,7 @@
{{if eq .ID "sites"}}
<div class="subnav">
<a href="/sites" {{if eq $nav "sites/site"}}aria-current="page"{{end}}>Sections and pages</a>
<a href="/sites/pages" {{if hasPrefix $nav "sites/pages"}}aria-current="page"{{end}}>New pages</a>
<a href="/sites/previews" {{if eq $nav "sites/previews"}}aria-current="page"{{end}}>Previews</a>
</div>
{{end}}
@@ -184,3 +185,15 @@
<nav class="tabs">{{range .Sites}}<a href="{{$d.Path}}?site={{.Index}}" {{if eq .Index $d.Current.Index}}aria-current="page"{{end}}>{{.URL}}</a>{{end}}</nav>
{{end}}
{{end}}
{{/* A Sites page's status, as a badge. */}}
{{define "page-status"}}
{{- if eq .Status "draft"}}<span class="badge draft">draft</span>
{{- else if eq .Status "working"}}<span class="badge scheduled">pushing…</span>
{{- else if eq .Status "pushed"}}<span class="badge scheduled">on its branch</span>
{{- else if eq .Status "pr"}}<span class="badge scheduled">pull request open</span>
{{- else if eq .Status "merged"}}<span class="badge published">merged</span>
{{- else if eq .Status "closed"}}<span class="badge">closed</span>
{{- else if eq .Status "failed"}}<span class="badge failed">failed</span>
{{- end}}{{if and .Error (ne .Status "failed")}} <span class="badge failed">to fix</span>{{end}}
{{end}}
+57
View File
@@ -0,0 +1,57 @@
{{define "content"}}{{with .Data}}{{$d := .}}{{$p := .P}}
<div class="heading"><h1>{{or $p.Title "New page"}}</h1></div>
<p class="lede">{{.Kind}} for {{$p.Site}}{{with .From}}, from {{join . "; "}}{{end}}.
{{template "page-status" $p}}</p>
{{if or $p.PRURL .Preview}}
<section class="card">
{{with .Preview}}<p><a class="button" href="{{.}}" target="_blank" rel="noopener">Open the preview ↗</a> <span class="small muted">built {{ago $d.PreviewAt}} from the branch {{$p.Branch}}</span></p>{{end}}
{{with $p.PRURL}}<p>The pull request: <a href="{{.}}" target="_blank" rel="noopener noreferrer">{{.}} ↗</a>{{if eq $p.Status "merged"}}, merged {{ago $p.MergedAt}}{{end}}</p>{{end}}
{{with $p.Note}}<p class="small">{{.}}</p>{{end}}
</section>
{{end}}
{{with $p.Error}}<p class="error" role="alert">{{.}}</p>{{end}}
{{if $p.Editable}}
<form method="post" action="/sites/pages/{{$p.ID}}/save" class="card">
<div class="cols">
<label>Title <span class="muted">(for search results, under 60 characters)</span> <input name="title" value="{{$p.Title}}" maxlength="120"></label>
<label>Address {{if $p.File}}<span class="muted">(fixed: the file is on its branch)</span>{{end}} <input name="path" value="{{$p.Path}}" {{if $p.File}}readonly{{end}}></label>
</div>
<label>Description <span class="muted">(under 155 characters)</span> <textarea name="description" rows="2">{{$p.Description}}</textarea></label>
{{with $p.Warnings}}
<div class="warn card"><strong>To look at:</strong><ul>{{range .}}<li>{{.}}</li>{{end}}</ul></div>
{{end}}
<label>Sections <span class="muted">(the page's front matter: your site's section types, as YAML)</span>
<textarea name="sections" rows="28" class="mono" spellcheck="false">{{$p.Sections}}</textarea></label>
<label>Still to add or check by hand <span class="muted">(one per line; listed in the pull request)</span>
<textarea name="needs" rows="3">{{lines $p.Needs}}</textarea></label>
<label>What the page is for <span class="muted">(used when it's written again)</span>
<textarea name="notes" rows="3">{{$p.Notes}}</textarea></label>
{{with $p.Claims}}
<fieldset><legend>Confirm these are true before the pull request</legend>
<p class="small muted">They claim experience, tests or results. Tick each one that's true; edit the sections to take out any that aren't.</p>
{{range .}}<label class="check"><input type="checkbox" name="confirm" value="{{.}}"> {{.}}</label>{{end}}
</fieldset>
{{end}}
<div class="actions">
<button type="submit" class="secondary">Save</button>
<button type="submit" class="secondary" formaction="/sites/pages/{{$p.ID}}/rewrite" data-busy="Writing…">Write it again</button>
<button type="submit" class="secondary" formaction="/sites/pages/{{$p.ID}}/preview" data-busy="Pushing and building…" {{if not $d.Gitea}}disabled{{end}}>Push and preview</button>
<button type="submit" formaction="/sites/pages/{{$p.ID}}/pr" data-busy="Opening…" {{if not $d.Gitea}}disabled{{end}}>{{if $p.PRNumber}}Update the pull request{{else}}Open a pull request{{end}}</button>
</div>
<p class="small muted"><em>Write it again</em> uses your notes above and keeps what you've edited as its starting point. <em>Push and preview</em> puts the page on its own branch ({{or $p.Branch "supermarket/site-page-…"}}) and builds a preview, without a pull request.</p>
</form>
{{else}}
<section class="card"><pre class="sample">{{$p.Sections}}</pre></section>
{{end}}
<form method="post" action="/sites/pages/{{$p.ID}}/delete" class="danger-zone">
<button type="submit" class="secondary" data-confirm="Forget this page? Its branch and pull request on Gitea stay.">Delete</button>
<span class="small muted">Forgets the page here. Its branch and pull request on Gitea stay; close them there.</span>
</form>
{{end}}{{end}}
+62
View File
@@ -0,0 +1,62 @@
{{define "content"}}{{with .Data}}{{$d := .}}
<div class="heading"><h1>New pages</h1></div>
<p class="lede">Pages for your website built from its own sections: a landing page, a product page, an alternative to a competitor, a comparison, or a blog post. The AI uses only the section types and fields your site already has. You review and edit the page here, preview it on its branch, and open a pull request; merging publishes it.</p>
{{if not .Sites}}
<section class="card empty"><p>Add your website and its Hugo repository under <a href="/settings/profile">Settings → Profile</a> first.</p></section>
{{else}}
{{if gt (len .Sites) 1}}<nav class="tabs">{{range .Sites}}<a href="/sites/pages?site={{.Index}}" {{if and $d.Current (eq .Index $d.Current.Index)}}aria-current="page"{{end}}>{{.URL}}</a>{{end}}</nav>{{end}}
{{with .Current}}{{$cur := .}}
{{if .Err}}
<section class="card"><p class="warn-text">{{.URL}}: {{.Err}}. Set it under <a href="/settings/profile">Settings → Profile</a>.</p></section>
{{else}}
<form method="post" action="/sites/pages" class="card">
<h2>A new page</h2>
<input type="hidden" name="site" value="{{.Index}}">
{{if not $d.AI}}<p class="warn-text">Building pages needs the AI: choose a provider under <a href="/settings/ai">Settings → AI</a>.</p>{{end}}
{{if not $d.Gitea}}<p class="warn-text">Supermarket reads the site with your Gitea token: save one under <a href="/settings/search">Settings → Search engines</a>.</p>{{end}}
<div class="cols">
<label>Kind of page
<select name="kind">{{range $d.Kinds}}<option value="{{.ID}}">{{.Label}}</option>{{end}}</select>
</label>
<label>Address <span class="muted">(optional)</span> <input name="path" placeholder="/for-churches/"></label>
</div>
<div class="cols">
<label>Product <span class="muted">(optional)</span>
<select name="product"><option value="">None</option>{{range $d.Products}}<option>{{.Name}}</option>{{end}}</select>
</label>
<label>Competitor <span class="muted">(alternative and comparison pages)</span>
<select name="competitor"><option value="">None</option>{{range $d.Competitors}}<option value="{{.ID}}">{{.Name}}</option>{{end}}</select>
</label>
</div>
<div class="cols">
<label>Buying signal <span class="muted">(optional; its links get the signal's campaign tag)</span>
<select name="signal"><option value="">None</option>{{range $d.Signals}}<option value="{{.ID}}">{{.Name}}</option>{{end}}</select>
</label>
<label>SEO brief <span class="muted">(optional)</span>
<select name="brief"><option value="">None</option>{{range $d.Briefs}}<option value="{{.ID}}">{{.Keyword}}</option>{{end}}</select>
</label>
</div>
<label>What the page is for <textarea name="notes" rows="3" placeholder="Who it's for, what it should get them to do, anything it must or mustn't say."></textarea></label>
<div class="actions">
<button type="submit" data-busy="Reading the site and writing…" {{if or (not $d.AI) (not $d.Gitea)}}disabled{{end}}>Build the page</button>
</div>
<p class="small muted">It reads the site's repository first, so it uses the latest sections. Writing takes a minute or two.</p>
</form>
<h2>Pages</h2>
{{with $d.Pages}}
<div class="table-wrap"><table>
<thead><tr><th>Page</th><th>Kind</th><th>Status</th><th>Started</th></tr></thead>
<tbody>{{range .}}<tr>
<td><a href="/sites/pages/{{.ID}}">{{or .Title "Untitled"}}</a><br><span class="small muted">{{.Path}}</span></td>
<td class="small">{{kindLabel .Kind}}</td>
<td>{{template "page-status" .}}</td>
<td class="small">{{ago .CreatedAt}}</td>
</tr>{{end}}</tbody>
</table></div>
{{else}}<p class="help">No pages built yet.</p>{{end}}
{{end}}
{{end}}
{{end}}
{{end}}{{end}}