Phase 6 part 5, step 1: a shared site theme

internal/theme embeds a Hugo theme from federated-website's look and the
13 section types both sites share, with the header, footer, colors, font
and logo set per site in hugo.toml, and a README of each type's fields.
The catalogue reader reads themes' sections and READMEs after the site's
own; lead forms know a theme site needs only the Lead Capture address.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 15:14:24 -07:00
co-authored by Claude Opus 5.5
parent 98913971ea
commit 5d7db5c5bf
36 changed files with 2641 additions and 79 deletions
+42 -4
View File
@@ -1375,10 +1375,48 @@ shared theme for new sites (deferred in Phase 5).
item 1: the second app's keys, choosing the page, and posting as the item 1: the second app's keys, choosing the page, and posting as the
page or the profile per draft. Built against LinkedIn's documented API; page or the profile per draft. Built against LinkedIn's documented API;
used for real once LinkedIn approves the app. used for real once LinkedIn approves the app.
5. **New sites from a shared theme.** A Hugo theme of sections common to 5. **New sites from a shared theme.** Decided with the user (2026-11-22):
federated-website and webcoredesktop, and creating a new site from it: the theme is *copied into* each new site (`themes/supermarket/`), not a
a new Gitea repository, a first set of pages built by Part 3 of Phase 5, submodule, so each site stands alone; *the user creates* the empty
and a preview. Planned in detail when it starts. Gitea repository (the `write:repository` token stays enough); the theme
has *federated-website's look*, with each site's colors, fonts and logo
as settings. In three steps, a commit after each:
1. **The theme**, embedded in Supermarket: base layouts, header and
footer, the section types both sites share (hero, text, features,
cards, steps, checklist, split, stats, table, faq, callout,
final-cta) plus federated-website's lead `form`, the stylesheet with
brand variables, and a README documenting each type and its fields
(which the catalogue reader and the page builder then use).
2. **A new site**: Sites → New site takes the empty repository, the
site's address, name and brand (colors, font, logo); the first
commit (the theme, `hugo.toml`, a starter home page) goes straight to
the empty repository's `main`, the one exception to "always a pull
request", since there's nothing published yet; then the site is added
to the profile, read, and previewed, and its first pages (home,
about, a product page, contact with a lead form) are built with the
page builder as pull requests.
3. **Theme updates**: the theme carries a version; a site whose copy is
older gets a pull request copying the new one in.
**Step 1 built (2026-11-22; no schema change).** `internal/theme` embeds
the theme (version 1): federated-website's base layout (its reveal and
sticky-header script; not its agent view or pricing script), a generic
head (title, description, canonical and Open Graph tags, favicon, the
brand font from Google Fonts, Plausible when `[params.plausible]` is
set), a header and footer driven by `hugo.toml` (logo or the site's
name, `main` menu with dropdowns, `[params.header] ctas`, footer
groups, social and legal menus, copyright), the 13 shared section types
(the hero without Federated's layer panel; the form posting through
`supermarket-leads.js`, now the theme's file and the one Part 3 uses),
pages that render sections then any Markdown body, a 404, and the
stylesheet with every brand color as a variable (the fixed violet,
lime and navy tints turned into `color-mix` of the brand variables).
`[params.brand]` sets dark, dark2, primary, accent (and hovers), font,
logo and favicon. The README documents each type's real fields; the
catalogue reader now reads `themes/*/` sections and READMEs after the
site's own (the site's win), and treats types `render-sections` picks
by name as types even before a page uses them; Lead forms knows a theme
site needs only the address. Tested with Hugo building every section.
**Part 1 built (2026-11-22; no schema change).** `internal/backup` makes **Part 1 built (2026-11-22; no schema change).** `internal/backup` makes
backups with `VACUUM INTO` (to a `.part` file, then renamed; mode 0600) backups with `VACUUM INTO` (to a `.part` file, then renamed; mode 0600)
+31 -8
View File
@@ -82,25 +82,36 @@ var (
partialRef = regexp.MustCompile(`partial\s+"sections/([\w-]+)\.html"\s*(?:(\$s|\.)(?:\s|-?\}\}|\)))?`) partialRef = regexp.MustCompile(`partial\s+"sections/([\w-]+)\.html"\s*(?:(\$s|\.)(?:\s|-?\}\}|\)))?`)
dollarS = regexp.MustCompile(`\$s\.([a-z]\w*)`) dollarS = regexp.MustCompile(`\$s\.([a-z]\w*)`)
bareDot = regexp.MustCompile(`(?:^|[\s(])\.([a-z]\w*)`) bareDot = regexp.MustCompile(`(?:^|[\s(])\.([a-z]\w*)`)
typeTest = regexp.MustCompile(`eq \.type "([\w-]+)"`)
readmeList = regexp.MustCompile("^\\s*[-*]\\s+`([\\w-]+)`\\s+[—–-]+\\s+(.+)$") readmeList = regexp.MustCompile("^\\s*[-*]\\s+`([\\w-]+)`\\s+[—–-]+\\s+(.+)$")
readmeRow = regexp.MustCompile("^\\|\\s*`([\\w-]+)`\\s*\\|\\s*(.+?)\\s*\\|\\s*$") readmeRow = regexp.MustCompile("^\\|\\s*`([\\w-]+)`\\s*\\|\\s*(.+?)\\s*\\|\\s*$")
) )
// Read reads the catalogue from a working copy of the site. // Read reads the catalogue from a working copy of the site.
func Read(dir string, pathOf PathFunc) (*Catalog, error) { func Read(dir string, pathOf PathFunc) (*Catalog, error) {
partDir := filepath.Join(dir, "layouts", "partials", "sections") // The site's own layouts, then its themes' (the site's win, as in Hugo).
roots := []string{dir}
if themes, err := filepath.Glob(filepath.Join(dir, "themes", "*")); err == nil {
sort.Strings(themes)
roots = append(roots, themes...)
}
partials := map[string]string{}
for _, root := range roots {
partDir := filepath.Join(root, "layouts", "partials", "sections")
entries, err := os.ReadDir(partDir) entries, err := os.ReadDir(partDir)
if err != nil && !os.IsNotExist(err) { if err != nil && !os.IsNotExist(err) {
return nil, err return nil, err
} }
partials := map[string]string{}
for _, e := range entries { for _, e := range entries {
if !e.IsDir() && strings.HasSuffix(e.Name(), ".html") { name := strings.TrimSuffix(e.Name(), ".html")
if e.IsDir() || !strings.HasSuffix(e.Name(), ".html") || partials[name] != "" {
continue
}
raw, err := os.ReadFile(filepath.Join(partDir, e.Name())) raw, err := os.ReadFile(filepath.Join(partDir, e.Name()))
if err != nil { if err != nil {
return nil, err return nil, err
} }
partials[strings.TrimSuffix(e.Name(), ".html")] = string(raw) partials[name] = string(raw)
} }
} }
// Partials named by another partial, or by render-sections, are // Partials named by another partial, or by render-sections, are
@@ -115,10 +126,17 @@ func Read(dir string, pathOf PathFunc) (*Catalog, error) {
} }
} }
} }
if raw, err := os.ReadFile(filepath.Join(dir, "layouts", "partials", "render-sections.html")); err == nil { dispatched := map[string]bool{} // types render-sections picks by name
for _, root := range roots {
if raw, err := os.ReadFile(filepath.Join(root, "layouts", "partials", "render-sections.html")); err == nil {
for _, m := range partialRef.FindAllStringSubmatch(string(raw), -1) { for _, m := range partialRef.FindAllStringSubmatch(string(raw), -1) {
referenced[m[1]] = true referenced[m[1]] = true
} }
for _, m := range typeTest.FindAllStringSubmatch(string(raw), -1) {
dispatched[m[1]] = true
}
break
}
} }
c := &Catalog{} c := &Catalog{}
@@ -135,7 +153,7 @@ func Read(dir string, pathOf PathFunc) (*Catalog, error) {
} }
root := filepath.Join(dir, "content") root := filepath.Join(dir, "content")
err = filepath.WalkDir(root, func(p string, d fs.DirEntry, err error) error { err := filepath.WalkDir(root, func(p string, d fs.DirEntry, err error) error {
if err != nil { if err != nil {
if os.IsNotExist(err) && p == root { if os.IsNotExist(err) && p == root {
return fs.SkipDir return fs.SkipDir
@@ -208,13 +226,18 @@ func Read(dir string, pathOf PathFunc) (*Catalog, error) {
} }
for name := range partials { for name := range partials {
if referenced[name] && uses[name] == nil { if referenced[name] && uses[name] == nil && !dispatched[name] {
c.Helpers = append(c.Helpers, name) c.Helpers = append(c.Helpers, name)
continue continue
} }
get(name) get(name)
} }
docs := readmeDocs(dir) docs := map[string]string{}
for i := len(roots) - 1; i >= 0; i-- { // the site's README wins
for k, v := range readmeDocs(roots[i]) {
docs[k] = v
}
}
for name, t := range uses { for name, t := range uses {
_, has := partials[name] _, has := partials[name]
t.Missing = !has t.Missing = !has
+19 -60
View File
@@ -15,6 +15,7 @@ import (
"supermarket/internal/api/gitea" "supermarket/internal/api/gitea"
"supermarket/internal/hugorepo" "supermarket/internal/hugorepo"
"supermarket/internal/seo" "supermarket/internal/seo"
"supermarket/internal/theme"
) )
// Lead forms: a site's `form` sections post to EspoCRM's Lead Capture // Lead forms: a site's `form` sections post to EspoCRM's Lead Capture
@@ -34,58 +35,9 @@ const LeadScriptPath = "static/js/supermarket-leads.js"
var LeadPayloadFields = []string{"First Name", "Last Name", "Email", "Account Name", "Phone", "Description"} var LeadPayloadFields = []string{"First Name", "Last Name", "Email", "Account Name", "Phone", "Description"}
// leadScript defines window.leadPost(form, data), which the form's own // leadScript defines window.leadPost(form, data), which the form's own
// script calls in place of its fetch: it returns the fetch's promise. // script calls in place of its fetch: it returns the fetch's promise. It's
const leadScript = `/* Sends the site's lead forms to EspoCRM's Lead Capture. Written by // the theme's, so new sites have it from the start.
Supermarket: the form posts here instead of to [params.leads] action var leadScript = theme.LeadScript()
directly, so its fields can be mapped onto a Lead's. */
(function () {
var mapped = { email: 'emailAddress', 'e-mail': 'emailAddress', phone: 'phoneNumber', tel: 'phoneNumber',
company: 'accountName', organization: 'accountName', organisation: 'accountName', church: 'accountName' };
function label(form, name) {
var el = form.querySelector('[name="' + name + '"]');
var l = el && el.id && form.querySelector('label[for="' + el.id + '"]');
return l ? l.childNodes[0].textContent.trim() : name;
}
window.leadPost = function (form, data) {
var lead = { firstName: null, lastName: null, emailAddress: null, accountName: null, phoneNumber: null };
var notes = [];
data.forEach(function (value, name) {
value = String(value).trim();
if (!value) return;
var key = name.toLowerCase();
if (key === 'name' || key === 'full_name' || key === 'fullname') {
var parts = value.split(/\s+/);
lead.lastName = parts.pop();
lead.firstName = parts.length ? parts.join(' ') : null;
} else if (key === 'first_name' || key === 'firstname') {
lead.firstName = value;
} else if (key === 'last_name' || key === 'lastname') {
lead.lastName = value;
} else if (mapped[key]) {
lead[mapped[key]] = value;
} else if (key === 'source') {
notes.unshift('Form: ' + value);
} else if (key === 'page') {
notes.push('Page: ' + location.origin + value);
} else {
notes.push(label(form, name) + ': ' + value);
}
});
if (!lead.lastName) lead.lastName = lead.emailAddress || 'Website visitor';
var q = new URLSearchParams(location.search);
['utm_campaign', 'utm_source', 'utm_medium', 'utm_content'].forEach(function (k) {
if (q.get(k)) notes.push(k + ': ' + q.get(k));
});
if (document.referrer) notes.push('Came from: ' + document.referrer);
lead.description = notes.join('\n') || null;
return fetch(form.action, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
body: JSON.stringify(lead)
});
};
})();
`
var ( var (
captureURL = regexp.MustCompile(`^https://[^/\s]+/(?:[^\s?#]*/)?api/v1/LeadCapture/[A-Za-z0-9]+$`) captureURL = regexp.MustCompile(`^https://[^/\s]+/(?:[^\s?#]*/)?api/v1/LeadCapture/[A-Za-z0-9]+$`)
@@ -216,10 +168,14 @@ func ReadForms(wc *hugorepo.Repo, cat *Catalog) FormState {
st.Action = LeadsAction(string(raw)) st.Action = LeadsAction(string(raw))
} }
} }
st.Script = wc.Exists(LeadScriptPath) st.Script = wc.Exists(LeadScriptPath) || wc.Exists(theme.Dir+"/"+LeadScriptPath)
if raw, err := os.ReadFile(wc.Dir + "/layouts/partials/sections/form.html"); err == nil { if raw, err := os.ReadFile(wc.Dir + "/layouts/partials/sections/form.html"); err == nil {
st.Patched = strings.Contains(string(raw), "window.leadPost") st.Patched = strings.Contains(string(raw), "window.leadPost")
_, st.Supported = PatchFormPartial(string(raw)) _, st.Supported = PatchFormPartial(string(raw))
} else if raw, err := os.ReadFile(wc.Dir + "/" + theme.Dir + "/layouts/partials/sections/form.html"); err == nil {
// The theme's form already posts through the script.
st.Patched = strings.Contains(string(raw), "window.leadPost")
st.Supported = st.Patched
} }
if cat != nil { if cat != nil {
if t := cat.Type("form"); t != nil { if t := cat.Type("form"); t != nil {
@@ -252,14 +208,18 @@ func ConnectForms(ctx context.Context, ap *seo.Applier, capture string, formPage
return nil, errors.New("the site's settings aren't in a TOML file (hugo.toml), which is all Supermarket can change for now") return nil, errors.New("the site's settings aren't in a TOML file (hugo.toml), which is all Supermarket can change for now")
} }
partial := "layouts/partials/sections/form.html" partial := "layouts/partials/sections/form.html"
raw, err := os.ReadFile(wc.Dir + "/" + partial) var files []struct{ path, body string }
if err != nil { if raw, err := os.ReadFile(wc.Dir + "/" + partial); err == nil {
return nil, errors.New("the site has no form section (layouts/partials/sections/form.html)")
}
patched, ok := PatchFormPartial(string(raw)) patched, ok := PatchFormPartial(string(raw))
if !ok { if !ok {
return nil, errors.New("the site's form section doesn't post the way Supermarket knows (a fetch of form.action with the form's data), so it can't be connected automatically") return nil, errors.New("the site's form section doesn't post the way Supermarket knows (a fetch of form.action with the form's data), so it can't be connected automatically")
} }
files = append(files, struct{ path, body string }{partial, patched}, struct{ path, body string }{LeadScriptPath, leadScript})
} else if raw, err := os.ReadFile(wc.Dir + "/" + theme.Dir + "/" + partial); err == nil && strings.Contains(string(raw), "window.leadPost") {
// Supermarket's theme: its form and script are ready; only the address is needed.
} else {
return nil, errors.New("the site has no form section (layouts/partials/sections/form.html)")
}
branch := "supermarket/lead-forms" branch := "supermarket/lead-forms"
if err := wc.NewBranch(ctx, branch); err != nil { if err := wc.NewBranch(ctx, branch); err != nil {
return nil, err return nil, err
@@ -268,9 +228,8 @@ func ConnectForms(ctx context.Context, ap *seo.Applier, capture string, formPage
if err != nil { if err != nil {
return nil, err return nil, err
} }
for _, f := range []struct{ path, body string }{ files = append(files, struct{ path, body string }{cfg, SetLeadsAction(string(cfgRaw), capture)})
{cfg, SetLeadsAction(string(cfgRaw), capture)}, {partial, patched}, {LeadScriptPath, leadScript}, for _, f := range files {
} {
if err := wc.WriteFile(f.path, f.body); err != nil { if err := wc.WriteFile(f.path, f.body); err != nil {
return nil, err return nil, err
} }
+49
View File
@@ -0,0 +1,49 @@
package sites
import (
"slices"
"strings"
"testing"
"supermarket/internal/theme"
)
func TestReadThemeSite(t *testing.T) {
files := map[string]string{
"hugo.toml": "theme = 'supermarket'\n",
"content/_index.md": "---\ntitle: Home\nsections:\n - type: hero\n title: Hi\n - type: faq\n items: [{q: A, a: B}]\n---\n",
"README.md": "| `faq` | the site's own words |\n",
"layouts/partials/sections/faq.html": "{{ $s := . }}{{ range $s.items }}{{ .q }}{{ .a }}{{ end }}",
}
for p, b := range theme.Files() {
files[theme.Dir+"/"+p] = b
}
dir := write(t, files)
c, err := Read(dir, path)
if err != nil {
t.Fatal(err)
}
var names []string
for _, ty := range c.Types {
names = append(names, ty.Name)
}
slices.Sort(names)
want := []string{"callout", "cards", "checklist", "faq", "features", "final-cta", "form", "hero", "split", "stats", "steps", "table", "text"}
if !slices.Equal(names, want) {
t.Errorf("types: %v", names)
}
if !slices.Equal(c.Helpers, []string{"ctas", "head", "wrapper"}) {
t.Errorf("helpers: %v", c.Helpers)
}
if d := c.Type("hero").Doc; !strings.Contains(d, "`eyebrow`, `title`, `subhead`") {
t.Errorf("hero doc from the theme: %q", d)
}
// The site's own README and layout win over the theme's.
faq := c.Type("faq")
if faq.Doc != "the site's own words" || slices.Contains(faq.Layout, "ctas") {
t.Errorf("faq: %+v", faq)
}
if c.Type("form").Missing || !slices.Contains(c.Type("table").Layout, "rows") {
t.Errorf("form/table: %+v %+v", c.Type("form"), c.Type("table"))
}
}
+75
View File
@@ -0,0 +1,75 @@
# The Supermarket site theme
A Hugo theme for websites made of sections, from Federated Computer's
design system. Supermarket copies it into a site as `themes/supermarket/`;
the site's `hugo.toml` says `theme = "supermarket"`. Anything in the site's
own `layouts/` or `static/` takes precedence over the theme's, so a site can
change any part of it.
## How pages are built
Every page's content lives in its front matter as a `sections:` list. Each
section has a `type` and the fields that type takes. Sections alternate
white and grey bands; `hero` opens the page as a dark band and `final-cta`
closes it as one.
Any section can take `id` (an anchor for links); without one it's made
from `kicker` or `headline`. Most take a heading: `kicker` (a small label
above), `headline` and `lede` (a sentence below). Buttons are `ctas`: a list
of `label`, `url` and `style` (`primary`, `ghost`, or `text` for a quiet
link). Text fields take Markdown inline (bold, links).
| Type | Fields |
|------|--------|
| `hero` | `eyebrow`, `title`, `subhead`, `ctas`, `compact` (shorter). Optional `log`: lines of `tag` + `text` (`think: true` for a greyed step, `done: true` to close) typed out in a console beside the copy, titled `logTitle`; `logImage` puts a photo behind the band, credited by `logCaption` |
| `text` | `kicker`, `headline`, `body` (Markdown), `centered`, `ctas`; `offer` adds a highlighted card below: `badge`, `text`, `ctas`. Without a headline, the body shows as a large statement |
| `features` | `kicker`, `headline`, `lede`, `intro` (Markdown), `items` of `label` + `body` |
| `cards` | `kicker`, `headline`, `lede`, `columns` (2 or 3), `items` of `label`, `title`, `body`, `image`, `link`, `linktext`; `visual: true` draws a panel where there's no image; `ctas` |
| `steps` | `kicker`, `headline`, `lede`, `items` of `title` + `body` |
| `checklist` | `kicker`, `headline`, `lede`, `items` (Markdown strings) |
| `split` | `kicker`, `headline`, `lede`, `columns` of `title` + `items` (short lists), `ctas` |
| `stats` | `kicker`, `headline`, `lede`, `items` of `value` + `label` (values starting with a number count up), `ctas` |
| `table` | A comparison: `kicker`, `headline`, `lede`, `headers` (one per column of values; the last is yours, highlighted), `rows` of `label` + `cells` (one value per header), `ctas` |
| `faq` | `kicker`, `headline`, `lede`, `items` of `q` + `a`, `ctas` |
| `callout` | `kicker`, `headline`, `intro`, `text` |
| `final-cta` | `headline`, `body`, `ctas` (the dark closing band) |
| `form` | A lead form: `kicker`, `headline`, `lede`, `points` (a list beside the form), `note`, `subject` (names the lead), `submit` (the button), `success` (shown after sending), `fields` of `name`, `label`, `type` (`text`, `email`, `number`, `select`, `textarea`), `options`, `placeholder`, `hint`, `required`, `half: true` (two to a row). It posts to `[params.leads] action` (EspoCRM's Lead Capture, set up by Supermarket); while that's empty it opens an email to `[params.leads] email` |
## Settings (hugo.toml)
```toml
theme = "supermarket"
[params]
tagline = "What the company does, in a line."
[params.brand]
logo = "/images/logo.svg" # without one, the site's title is shown
favicon = "/favicon.svg"
dark = "#001a2b" # the top bar, hero and closing band
dark2 = "#052b42"
primary = "#e0ff4f" # the main button
accent = "#614efa" # links and highlights
font = "Inter" # a Google Fonts family
[params.header]
ctas = [{ label = "Get started", url = "/contact/", style = "primary" }]
[params.footer]
tagline = "..."
place = "City, Country"
copyright = "© 2026 Company, Inc."
groups = [{ title = "Company", menu = "footer_company" }]
[params.leads]
action = ""
email = "hello@example.com"
[params.plausible]
script = "https://plausible.example.com/js/script.js"
domain = "example.com"
```
The top bar shows the `main` menu (`[[menu.main]]`); an entry with
`params.dropdown = "<menu>"` opens that menu as a panel. The footer shows
the menus its groups name, `footer_social` and `footer_legal`.
+8
View File
@@ -0,0 +1,8 @@
{{ define "main" }}
<header class="hero hero-compact">
<div class="wrap hero-grid"><div class="hero-copy">
<h1 class="statement">Page not found</h1>
<p class="dek">There's nothing at this address. Try the <a href="{{ "/" | relURL }}">home page</a>.</p>
</div></div>
</header>
{{ end }}
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="{{ site.Language.LanguageCode | default "en" }}">
<head>
{{ partial "head.html" . }}
</head>
<body id="top">
<a class="skip" href="#content">Skip to content</a>
{{ partial "header.html" . }}
<main id="content" tabindex="-1">
{{ block "main" . }}{{ end }}
</main>
{{ partial "footer.html" . }}
<script>
/* Progressive only: fade sections in as they scroll into view, and
darken the top bar once the page has scrolled. */
(function () {
var root = document.documentElement;
var head = document.querySelector('.site-head');
function onScroll() { if (head) head.classList.toggle('is-scrolled', scrollY > 8); }
addEventListener('scroll', onScroll, { passive: true });
onScroll();
if (!('IntersectionObserver' in window)) return;
root.classList.add('js');
var io = new IntersectionObserver(function (entries) {
entries.forEach(function (e) {
if (e.isIntersecting) { e.target.classList.add('is-visible'); io.unobserve(e.target); }
});
}, { rootMargin: '0px 0px -8% 0px' });
document.querySelectorAll('[data-reveal]').forEach(function (el) { io.observe(el); });
})();
</script>
</body>
</html>
@@ -0,0 +1,4 @@
{{ define "main" }}
{{ partial "render-sections.html" . }}
{{ with .Content }}<div class="wrap prose page-body">{{ . }}</div>{{ end }}
{{ end }}
@@ -0,0 +1,4 @@
{{ define "main" }}
{{ partial "render-sections.html" . }}
{{ with .Content }}<div class="wrap prose page-body">{{ . }}</div>{{ end }}
{{ end }}
+4
View File
@@ -0,0 +1,4 @@
{{ define "main" }}
{{ partial "render-sections.html" . }}
{{ with .Content }}<div class="wrap prose page-body">{{ . }}</div>{{ end }}
{{ end }}
@@ -0,0 +1,45 @@
{{/*
The footer: the brand, [params.footer] tagline and place, the social
links (menu footer_social), the link groups in [params.footer] groups
(each a title and a menu's name), the legal links (menu footer_legal),
and the copyright line.
*/}}
{{ $b := site.Params.brand | default dict }}
{{ $f := site.Params.footer | default dict }}
<footer class="foot">
<div class="wrap">
<div class="foot-top-row">
<div class="foot-brand">
<a href="{{ "/" | relURL }}" class="foot-mark" aria-label="{{ site.Title }}, home">
{{ with $b.logo }}<img src="{{ . | relURL }}" alt="{{ site.Title }}" class="brand-logo">{{ else }}<span class="brand-name">{{ site.Title }}</span>{{ end }}
</a>
{{ with $f.tagline | default site.Params.tagline }}<p class="foot-line">{{ . }}</p>{{ end }}
{{ with $f.place }}<span class="foot-place">{{ . }}</span>{{ end }}
{{ with site.Menus.footer_social }}
<ul class="foot-social">
{{ range . }}<li><a href="{{ .URL }}" target="_blank" rel="noopener">{{ .Name }}<span class="arrow" aria-hidden="true">↗</span></a></li>{{ end }}
</ul>
{{ end }}
</div>
<div class="foot-grid">
{{ range $f.groups }}
<nav class="foot-group" aria-label="{{ .title }}">
<span class="foot-head">{{ .title }}</span>
<ul class="foot-links">
{{ range index site.Menus .menu }}
<li><a href="{{ if or (hasPrefix .URL "mailto:") (hasPrefix .URL "http") }}{{ .URL }}{{ else }}{{ .URL | relURL }}{{ end }}"{{ if .Params.external }} target="_blank" rel="noopener"{{ end }}>{{ .Name }}{{ if .Params.external }}<span class="arrow" aria-hidden="true">↗</span>{{ end }}</a></li>
{{ end }}
</ul>
</nav>
{{ end }}
</div>
</div>
<div class="foot-legal">
<span class="foot-copy">{{ with $f.copyright }}{{ . }}{{ else }}© {{ now.Format "2006" }} {{ site.Title }}{{ end }}</span>
{{ range site.Menus.footer_legal }}<a class="foot-policy" href="{{ .URL | relURL }}">{{ .Name }}</a>{{ end }}
<a class="foot-top" href="#top">Back to top<span class="foot-up" aria-hidden="true">↑</span></a>
</div>
</div>
</footer>
@@ -0,0 +1,43 @@
{{/* Brand settings ([params.brand] in hugo.toml) override the stylesheet's
colors and font; see the theme's README. */}}
{{ $b := site.Params.brand | default dict }}
{{ $dark := $b.dark | default "#001a2b" }}
{{ $dark2 := $b.dark2 | default "#052b42" }}
{{ $primary := $b.primary | default "#e0ff4f" }}
{{ $accent := $b.accent | default "#614efa" }}
{{ $font := $b.font | default "Inter" }}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ if .IsHome }}{{ site.Title }}{{ with site.Params.tagline }} — {{ . }}{{ end }}{{ else }}{{ .Title }} · {{ site.Title }}{{ end }}</title>
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{ site.Params.tagline }}{{ end }}">
<meta name="theme-color" content="{{ $dark }}">
<link rel="canonical" href="{{ .Permalink }}">
<meta property="og:title" content="{{ .Title | default site.Title }}">
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{ site.Params.tagline }}{{ end }}">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:type" content="website">
{{ with $b.favicon }}<link rel="icon" href="{{ . | relURL }}">{{ end }}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family={{ $font }}:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="{{ "css/supermarket.css" | relURL }}">
<style>
:root {
--navy-deep: {{ $dark | safeCSS }}; --ink: {{ $dark | safeCSS }};
--navy: {{ $dark2 | safeCSS }}; --navy-2: {{ $dark2 | safeCSS }};
--lime: {{ $primary | safeCSS }}; --lime-deep: {{ $b.primaryHover | default $primary | safeCSS }}; --live: {{ $primary | safeCSS }};
--violet: {{ $accent | safeCSS }}; --violet-deep: {{ $b.accentHover | default $accent | safeCSS }};
--violet-7: color-mix(in srgb, {{ $accent | safeCSS }} 7%, transparent);
--violet-11: color-mix(in srgb, {{ $accent | safeCSS }} 11%, transparent);
--ink-86: color-mix(in srgb, {{ $dark | safeCSS }} 86%, transparent);
--ink-68: color-mix(in srgb, {{ $dark | safeCSS }} 68%, transparent);
--ink-60: color-mix(in srgb, {{ $dark | safeCSS }} 60%, transparent);
--ink-45: color-mix(in srgb, {{ $dark | safeCSS }} 45%, transparent);
--ink-22: color-mix(in srgb, {{ $dark | safeCSS }} 22%, transparent);
--font: "{{ $font | safeCSS }}", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
</style>
{{ with site.Params.plausible }}{{ if .script }}
<script defer data-domain="{{ .domain | default (urls.Parse site.BaseURL).Host }}" src="{{ .script }}"></script>
<script>window.plausible = window.plausible || function () { (window.plausible.q = window.plausible.q || []).push(arguments) };</script>
{{ end }}{{ end }}
@@ -0,0 +1,63 @@
{{/*
The top bar: the logo (or the site's name), the main menu (a menu entry
with `params.dropdown = "<menu>"` opens that menu as a panel), and the
buttons in [params.header] ctas. Below 1000px the menu folds into a Menu
toggle (a <details>, so it works without JS).
*/}}
{{ $page := . }}
{{ $b := site.Params.brand | default dict }}
{{ $ctas := (site.Params.header | default dict).ctas }}
<header class="site-head">
<div class="wrap head-bar">
<a href="{{ "/" | relURL }}" class="brand" aria-label="{{ site.Title }}, home">
{{ with $b.logo }}<img src="{{ . | relURL }}" alt="{{ site.Title }}" class="brand-logo">{{ else }}<span class="brand-name">{{ site.Title }}</span>{{ end }}
</a>
<nav class="head-nav" aria-label="Site">
{{ range .Site.Menus.main }}
{{ if ne .URL "/" }}
{{ $m := . }}
{{ $active := hasPrefix $page.RelPermalink .URL }}
{{ with .Params.dropdown }}
<div class="nav-item has-drop">
<a href="{{ $m.URL | relURL }}" class="nav-link"{{ if $active }} aria-current="page"{{ end }}>{{ $m.Name }}<svg class="nav-caret" viewBox="0 0 10 6" width="10" height="6" aria-hidden="true"><path d="M1 1l4 4 4-4" fill="none" stroke="currentColor" stroke-width="1.5"/></svg></a>
<div class="drop">
<div class="drop-panel">
{{ range index $page.Site.Menus . }}
<a href="{{ .URL | relURL }}" class="drop-link"{{ if eq $page.RelPermalink .URL }} aria-current="page"{{ end }}>
<span class="drop-name">{{ .Name }}</span>
{{ with .Params.desc }}<span class="drop-desc">{{ . }}</span>{{ end }}
</a>
{{ end }}
</div>
</div>
</div>
{{ else }}
<a href="{{ $m.URL | relURL }}" class="nav-link"{{ if $active }} aria-current="page"{{ end }}>{{ $m.Name }}</a>
{{ end }}
{{ end }}
{{ end }}
</nav>
{{ with $ctas }}
<div class="head-actions">
{{ range . }}<a href="{{ .url | relURL }}" class="{{ if eq .style "ghost" }}head-signin{{ else }}btn btn-primary btn-sm{{ end }}">{{ .label }}</a>{{ end }}
</div>
{{ end }}
<details class="menu">
<summary><span class="menu-word">Menu</span><span class="menu-glyph" aria-hidden="true"><i></i><i></i></span></summary>
<nav class="menu-panel" aria-label="Site">
{{ range .Site.Menus.main }}
<a href="{{ .URL | relURL }}" class="menu-top">{{ .Name }}</a>
{{ with .Params.dropdown }}
<div class="menu-sub">
{{ range index $page.Site.Menus . }}<a href="{{ .URL | relURL }}">{{ .Name }}</a>{{ end }}
</div>
{{ end }}
{{ end }}
{{ with $ctas }}<div class="menu-actions">{{ partial "sections/ctas.html" . }}</div>{{ end }}
</nav>
</details>
</div>
</header>
@@ -0,0 +1,9 @@
{{ range .Params.sections }}
{{ if eq .type "hero" }}
{{ partial "sections/hero.html" . }}
{{ else if eq .type "final-cta" }}
{{ partial "sections/final-cta.html" . }}
{{ else if templates.Exists (printf "partials/sections/%s.html" .type) }}
{{ partial "sections/wrapper.html" . }}
{{ end }}
{{ end }}
@@ -0,0 +1,11 @@
{{/*
Anchor id for a section: its own `id`, else one made from its `toc`,
`kicker`, or `headline`. Used by the section wrapper.
*/}}
{{ $id := "" }}
{{ with .id }}
{{ $id = . }}
{{ else }}
{{ with (or .toc .kicker .headline) }}{{ $id = . | plainify | anchorize }}{{ end }}
{{ end }}
{{ return $id }}
@@ -0,0 +1,4 @@
{{ $s := . }}
{{ partial "sections/head.html" $s }}
{{ with $s.intro }}<div class="prose mb-2">{{ . | markdownify }}</div>{{ end }}
<div class="callout"><p>{{ $s.text | markdownify }}</p></div>
@@ -0,0 +1,22 @@
{{/*
A grid of cards: `items`, each with `title`, `body`, optional `label`
(a small tag above the title), `image`, and `link` (+ `linktext`).
Without an image, `visual: true` draws a gradient panel in its place.
*/}}
{{ $s := . }}
{{ partial "sections/head.html" $s }}
<ul class="card-grid{{ with $s.columns }} cols-{{ . }}{{ end }}">
{{ range $i, $c := $s.items }}
<li class="card{{ if or $c.image $s.visual }} has-visual{{ end }}">
{{ with $c.image }}<img class="card-visual" src="{{ . | relURL }}" alt="" loading="lazy">
{{ else }}{{ if $s.visual }}<span class="card-visual card-art" style="--i:{{ $i }}" aria-hidden="true"></span>{{ end }}{{ end }}
<div class="card-body">
{{ with $c.label }}<span class="card-label">{{ . }}</span>{{ end }}
<h3 class="card-title">{{ $c.title | markdownify }}</h3>
{{ with $c.body }}<p class="card-text">{{ . | markdownify }}</p>{{ end }}
{{ with $c.link }}<a class="more card-link" href="{{ . | relURL }}">{{ replaceRE `\s*[→↗]\s*$` "" ($c.linktext | default "Learn more") }}<span class="arrow" aria-hidden="true">→</span></a>{{ end }}
</div>
</li>
{{ end }}
</ul>
{{ if $s.ctas }}<div class="cta-row">{{ partial "sections/ctas.html" $s.ctas }}</div>{{ end }}
@@ -0,0 +1,5 @@
{{ $s := . }}
{{ partial "sections/head.html" $s }}
<ul class="check-list">
{{ range $s.items }}<li>{{ . | markdownify }}</li>{{ end }}
</ul>
@@ -0,0 +1,17 @@
{{/*
Buttons. `primary` is the solid lime button, `ghost` the outlined
secondary, `text` a quiet link with an arrow. Any trailing "→" in a
label is dropped — the arrow is drawn.
*/}}
{{ range . }}
{{ $label := replaceRE `\s*[→↗]\s*$` "" .label }}
{{ $external := or (hasPrefix .url "http") (hasPrefix .url "mailto:") }}
{{ $href := cond (or $external (hasPrefix .url "#")) .url (.url | relURL) }}
{{ if eq .style "ghost" }}
<a href="{{ $href }}" class="btn btn-secondary">{{ $label }}<span class="arrow" aria-hidden="true">{{ if $external }}↗{{ else }}→{{ end }}</span></a>
{{ else if eq .style "text" }}
<a href="{{ $href }}" class="more">{{ $label }}<span class="arrow" aria-hidden="true">{{ if $external }}↗{{ else }}→{{ end }}</span></a>
{{ else }}
<a href="{{ $href }}" class="btn btn-primary">{{ $label }}<span class="arrow" aria-hidden="true">{{ if $external }}↗{{ else }}→{{ end }}</span></a>
{{ end }}
{{ end }}
@@ -0,0 +1,11 @@
{{ $s := . }}
{{ partial "sections/head.html" $s }}
<div class="faq-list">
{{ range $s.items }}
<details class="faq-item">
<summary>{{ .q }}</summary>
<div class="faq-answer"><p>{{ .a | markdownify }}</p></div>
</details>
{{ end }}
</div>
{{ if $s.ctas }}<div class="cta-row mt-2">{{ partial "sections/ctas.html" $s.ctas }}</div>{{ end }}
@@ -0,0 +1,8 @@
{{ $s := . }}
{{ partial "sections/head.html" $s }}
{{ with $s.intro }}<div class="prose mb-2">{{ . | markdownify }}</div>{{ end }}
<ul class="feature-list">
{{ range $s.items }}
<li><strong>{{ .label }}</strong>{{ .body | markdownify }}</li>
{{ end }}
</ul>
@@ -0,0 +1,10 @@
{{ $s := . }}
<aside class="cta" data-reveal>
<div class="wrap cta-inner">
<div class="cta-copy">
<h2 class="cta-title">{{ $s.headline | markdownify }}</h2>
{{ with $s.body }}<p class="cta-text">{{ . | markdownify }}</p>{{ end }}
</div>
{{ if $s.ctas }}<div class="actions">{{ partial "sections/ctas.html" $s.ctas }}</div>{{ end }}
</div>
</aside>
@@ -0,0 +1,103 @@
{{/*
A lead form: the heading, lede, and an optional `points` list on the
left; the form on the right. `fields` take `name`, `label`, `type`
(text, email, number, select, textarea; default text), optional
`options` (select), `placeholder`, `hint`, `required`, and `half: true`
to sit two to a row. `submit` labels the button; `subject` names the lead
(e.g. "Partner platform"); `success` is shown once it's sent.
Where it goes: `[params.leads] action` in hugo.toml. When set, the form
POSTs its fields there (with `source` and `page` added) and shows
`success`. When empty, it opens an email to `[params.leads] email` with
the answers filled in, so leads still arrive before a backend exists.
Without JS, the form falls back to a plain POST (or mailto) of the same.
*/}}
<script src="{{ "js/supermarket-leads.js" | relURL }}"></script>
{{ $s := . }}
{{ $leads := site.Params.leads | default dict }}
{{ $action := $leads.action | default "" }}
{{ $email := $leads.email | default site.Params.supportEmail }}
{{ $subject := $s.subject | default "Website inquiry" }}
<div class="lead">
<div class="lead-copy">
{{ partial "sections/head.html" $s }}
{{ with $s.points }}
<ul class="check-list lead-points">
{{ range . }}<li>{{ . | markdownify }}</li>{{ end }}
</ul>
{{ end }}
{{ with $s.note }}<p class="lead-note">{{ . | markdownify }}</p>{{ end }}
</div>
<form class="lead-form"
{{ if $action }}action="{{ $action }}" method="post"{{ else }}action="{{ printf "mailto:%s?subject=%s" $email (replace (urlquery $subject) "+" "%20") | safeURL }}" method="post" enctype="text/plain"{{ end }}
data-lead="{{ if $action }}post{{ else }}mailto{{ end }}"
data-email="{{ $email }}" data-subject="{{ $subject }}">
<input type="hidden" name="source" value="{{ $subject }}">
{{ range $i, $f := $s.fields }}
{{ $id := printf "lead-%s" $f.name }}
{{ $type := $f.type | default "text" }}
<div class="field{{ if $f.half }} field-half{{ end }}">
<label for="{{ $id }}">{{ $f.label }}{{ if not $f.required }} <span class="field-optional">Optional</span>{{ end }}</label>
{{ if eq $type "select" }}
<select id="{{ $id }}" name="{{ $f.name }}"{{ if $f.required }} required{{ end }}>
<option value="" disabled selected>{{ $f.placeholder | default "Choose one" }}</option>
{{ range $f.options }}<option>{{ . }}</option>{{ end }}
</select>
{{ else if eq $type "textarea" }}
<textarea id="{{ $id }}" name="{{ $f.name }}" rows="3"{{ with $f.placeholder }} placeholder="{{ . }}"{{ end }}{{ if $f.required }} required{{ end }}></textarea>
{{ else }}
<input id="{{ $id }}" name="{{ $f.name }}" type="{{ $type }}"{{ with $f.placeholder }} placeholder="{{ . }}"{{ end }}{{ if eq $type "email" }} autocomplete="email"{{ else if eq $f.name "name" }} autocomplete="name"{{ else if in (slice "company" "organization") $f.name }} autocomplete="organization"{{ end }}{{ if eq $type "number" }} min="0" inputmode="numeric"{{ end }}{{ if $f.required }} required{{ end }}>
{{ end }}
{{ with $f.hint }}<small>{{ . }}</small>{{ end }}
</div>
{{ end }}
<button type="submit" class="btn btn-primary">{{ $s.submit | default "Send" }}<span class="arrow" aria-hidden="true">→</span></button>
<p class="lead-status" role="status" aria-live="polite" hidden></p>
<p class="lead-privacy">We'll use this only to reply to you. No newsletters unless you ask. See our <a href="{{ "/privacy-policy/" | relURL }}">Privacy Policy</a>.</p>
</form>
</div>
<script>
(function () {
var form = document.currentScript.previousElementSibling.querySelector('form');
var status = form.querySelector('.lead-status');
var success = {{ $s.success | default "Thanks — we've got it and will be in touch soon." }};
function show(msg, ok) {
status.hidden = false;
status.textContent = msg;
status.className = 'lead-status ' + (ok ? 'is-ok' : 'is-error');
}
form.addEventListener('submit', function (e) {
if (!form.checkValidity()) return;
e.preventDefault();
var data = new FormData(form);
data.append('page', location.pathname);
if (window.plausible) plausible('Lead', { props: { source: form.dataset.subject } });
if (form.dataset.lead === 'mailto') {
var lines = [];
form.querySelectorAll('.field').forEach(function (f) {
var el = f.querySelector('input, select, textarea');
lines.push(f.querySelector('label').childNodes[0].textContent.trim() + ': ' + (el.value || '—'));
});
location.href = 'mailto:' + form.dataset.email + '?subject=' + encodeURIComponent(form.dataset.subject) +
'&body=' + encodeURIComponent(lines.join('\n') + '\n\nPage: ' + location.href);
show('Your email app should open with your answers filled in. Just press send.', true);
return;
}
var btn = form.querySelector('button');
btn.disabled = true;
(window.leadPost ? window.leadPost(form, data) : fetch(form.action, { method: 'POST', body: data, headers: { Accept: 'application/json' } }))
.then(function (r) {
if (!r.ok) throw new Error(r.status);
form.reset();
form.querySelectorAll('.field').forEach(function (f) { f.hidden = true; });
btn.hidden = true;
show(success, true);
})
.catch(function () {
btn.disabled = false;
show('Something went wrong sending that. Please try again, or email ' + form.dataset.email + '.', false);
});
});
})();
</script>
@@ -0,0 +1,8 @@
{{/* Shared section heading: optional kicker (a mono eyebrow), headline, and lede. */}}
{{ if or .kicker .headline .lede }}
<div class="section-head">
{{ with .kicker }}<p class="eyebrow">{{ . }}</p>{{ end }}
{{ with .headline }}<h2>{{ . | markdownify }}</h2>{{ end }}
{{ with .lede }}<p class="lede">{{ . | markdownify }}</p>{{ end }}
</div>
{{ end }}
@@ -0,0 +1,93 @@
{{/*
The opening of every page: a full-bleed dark band. On the left, an
optional note (the eyebrow), the statement (title), the dek (subhead) and
the actions (ctas); on the right, when `log:` is set, an activity log
typed out line by line. `compact: true` makes it shorter; `logImage` sets
a photo behind the whole band (`logCaption` credits it).
*/}}
{{ $s := . }}
{{ $visual := $s.log }}
<header class="hero{{ if $s.compact }} hero-compact{{ end }}{{ if $visual }} has-visual{{ end }}{{ if $s.logImage }} has-image{{ end }}">
{{ with $s.logImage }}<img class="hero-bg" src="{{ . | relURL }}" alt="" fetchpriority="high">{{ end }}
<div class="wrap hero-grid">
<div class="hero-copy">
{{ with $s.eyebrow }}<p class="note" data-reveal><span class="note-live" aria-hidden="true"></span><span class="note-text">{{ . }}</span></p>{{ end }}
<h1 class="statement" data-reveal style="--d:80ms">{{ $s.title | markdownify }}</h1>
{{ with $s.subhead }}<p class="dek" data-reveal style="--d:140ms">{{ . | markdownify }}</p>{{ end }}
{{ if $s.ctas }}<div class="actions" data-reveal style="--d:200ms">{{ partial "sections/ctas.html" $s.ctas }}</div>{{ end }}
</div>
{{ with $s.log }}
{{/*
An agent's activity log, typed out line by line (see the script below).
Lines take `tag` + `text`; `think: true` marks a reasoning step (greyed,
with a pause); `done: true` closes the run. The window keeps a fixed
height and scrolls as lines arrive. `logCaption` credits the photo.
*/}}
<figure class="hero-log" data-reveal style="--d:260ms">
<div class="log-window">
<div class="log-bar">
<span class="log-title">{{ $s.logTitle | default "activity" }}</span>
<span class="log-live"><span class="note-live" aria-hidden="true"></span>Live</span>
</div>
<div class="log-view">
<ol class="log-lines" aria-label="{{ $s.logTitle | default "Activity" }}">
{{ range . }}
<li class="log-line{{ if .done }} is-done{{ end }}{{ if .think }} is-think{{ end }}">
<span class="log-tag">{{ .tag | default (cond .done "Done" (cond (.think | default false) "Thinking" "")) }}</span>
<span class="log-text">{{ .text }}</span>
</li>
{{ end }}
</ol>
</div>
</div>
</figure>
<script>
(function () {
var fig = document.currentScript.previousElementSibling;
if (!fig || matchMedia('(prefers-reduced-motion: reduce)').matches) return;
var view = fig.querySelector('.log-view'), list = fig.querySelector('.log-lines');
var lines = [].slice.call(fig.querySelectorAll('.log-line'));
var onScreen = true, i = 0;
function visible() { return onScreen && !document.hidden; }
fig.classList.add('is-animated');
lines.forEach(function (li) {
li.style.setProperty('--n', li.querySelector('.log-text').textContent.trim().length);
});
// Pause while the log is off screen or the tab is hidden.
function schedule(fn, ms) { setTimeout(function () { if (visible()) fn(); else schedule(fn, 400); }, ms); }
function next() {
if (i === lines.length) { schedule(reset, 4200); return; }
var li = lines[i++], n = +li.style.getPropertyValue('--n');
// Finished lines drop their typing animation, so a repaint can't replay it.
lines.forEach(function (l) { if (l.classList.contains('is-current')) l.classList.add('is-typed'); l.classList.remove('is-current'); });
li.classList.add('is-on', 'is-current');
// Keep the newest line in view, like a terminal: slide the list up.
var shift = Math.max(0, li.offsetTop + li.offsetHeight + 18 - view.clientHeight);
list.style.transform = 'translateY(' + -shift + 'px)';
var pause = li.classList.contains('is-think') ? 1300 : li.classList.contains('is-done') ? 300 : 450;
schedule(next, n * 16 + pause);
}
function reset() {
fig.classList.add('is-clearing');
schedule(function () {
lines.forEach(function (l) { l.classList.remove('is-on', 'is-current', 'is-typed'); });
list.style.transition = 'none';
list.style.transform = '';
void list.offsetHeight;
list.style.transition = '';
fig.classList.remove('is-clearing');
i = 0;
schedule(next, 500);
}, 450);
}
if ('IntersectionObserver' in window) {
new IntersectionObserver(function (e) { onScreen = e[0].isIntersecting; }).observe(fig);
}
schedule(next, 700);
})();
</script>
{{ end }}
</div>
{{ with $s.logCaption }}<p class="hero-caption">{{ . }}</p>{{ end }}
</header>
@@ -0,0 +1,14 @@
{{/* Two columns, each a heading plus a short list. */}}
{{ $s := . }}
{{ partial "sections/head.html" $s }}
<div class="split">
{{ range $s.columns }}
<div class="split-col">
<h3>{{ .title }}</h3>
<ul class="split-list">
{{ range .items }}<li>{{ . | markdownify }}</li>{{ end }}
</ul>
</div>
{{ end }}
</div>
{{ if $s.ctas }}<div class="cta-row mt-2">{{ partial "sections/ctas.html" $s.ctas }}</div>{{ end }}
@@ -0,0 +1,45 @@
{{/*
Stat tiles. Values that start with a number ("80%+", "100+", "30X") count
up from zero when the row scrolls into view; others show as written.
Without JS or with reduced motion, every value simply shows.
*/}}
{{ $s := . }}
{{ partial "sections/head.html" $s }}
<div class="stat-row">
{{ range $s.items }}
<div class="stat">
<span class="stat-value">{{ .value }}</span>
<span class="stat-label">{{ .label }}</span>
</div>
{{ end }}
</div>
<script>
(function () {
var row = document.currentScript.previousElementSibling;
if (!('IntersectionObserver' in window) || matchMedia('(prefers-reduced-motion: reduce)').matches) return;
var counters = [];
row.querySelectorAll('.stat-value').forEach(function (el) {
var m = el.textContent.trim().match(/^(\d+)(.*)$/);
if (!m) return;
var shown = document.createElement('span'), full = el.textContent.trim();
shown.setAttribute('aria-hidden', 'true');
shown.textContent = '0' + m[2];
el.innerHTML = '<span class="visually-hidden"></span>';
el.firstChild.textContent = full;
el.appendChild(shown);
counters.push({ node: shown, to: +m[1], suffix: m[2] });
});
if (!counters.length) return;
new IntersectionObserver(function (entries, io) {
if (!entries[0].isIntersecting) return;
io.disconnect();
var start = performance.now(), dur = 1200;
(function tick(now) {
var t = Math.min(1, (now - start) / dur), eased = 1 - Math.pow(1 - t, 3);
counters.forEach(function (c) { c.node.textContent = Math.round(c.to * eased) + c.suffix; });
if (t < 1) requestAnimationFrame(tick);
})(start);
}, { threshold: 0.6 }).observe(row);
})();
</script>
{{ if $s.ctas }}<div class="cta-row mt-2">{{ partial "sections/ctas.html" $s.ctas }}</div>{{ end }}
@@ -0,0 +1,13 @@
{{ $s := . }}
{{ partial "sections/head.html" $s }}
<ol class="step-row{{ if eq (len $s.items) 4 }} steps-4{{ end }}">
{{ range $i, $item := $s.items }}
<li class="step">
<div class="step-head">
<h3>{{ $item.title }}</h3>
<span class="step-num">{{ printf "%03d" (add $i 1) }}</span>
</div>
<p>{{ $item.body | markdownify }}</p>
</li>
{{ end }}
</ol>
@@ -0,0 +1,28 @@
{{ $s := . }}
{{ partial "sections/head.html" $s }}
<div class="table-scroll">
<table class="compare-table">
<thead>
<tr>
<th></th>
{{ range $s.headers }}<th>{{ . }}</th>{{ end }}
</tr>
</thead>
<tbody>
{{ range $s.rows }}
{{ $n := len .cells }}
<tr>
<th>{{ .label }}</th>
{{ range $i, $cell := .cells }}
{{ if eq (add $i 1) $n }}
<td class="good">{{ $cell }}</td>
{{ else }}
<td class="bad">{{ $cell }}</td>
{{ end }}
{{ end }}
</tr>
{{ end }}
</tbody>
</table>
</div>
{{ if $s.ctas }}<div class="cta-row mt-2">{{ partial "sections/ctas.html" $s.ctas }}</div>{{ end }}
@@ -0,0 +1,20 @@
{{/*
Prose, with optional `ctas`. `offer` adds a highlighted card below:
`badge` (a small lime tag), `text`, and `ctas`.
*/}}
{{ $s := . }}
{{ partial "sections/head.html" $s }}
{{/* markdownify drops the <p> around a lone paragraph; put it back so inline markup stays in the flow */}}
{{ $body := $s.body | markdownify }}
{{ if not (findRE `^\s*<(p|ul|ol|h[1-6]|div|blockquote|pre|table|figure|hr)[\s>]` $body) }}{{ $body = printf "<p>%s</p>" $body | safeHTML }}{{ end }}
<div class="prose{{ if $s.centered }} centered{{ end }}">
{{ $body }}
</div>
{{ if $s.ctas }}<div class="cta-row mt-2">{{ partial "sections/ctas.html" $s.ctas }}</div>{{ end }}
{{ with $s.offer }}
<div class="offer-card">
{{ with .badge }}<span class="offer-badge">{{ . }}</span>{{ end }}
<p class="offer-text">{{ .text | markdownify }}</p>
{{ with .ctas }}<div class="offer-actions">{{ partial "sections/ctas.html" . }}</div>{{ end }}
</div>
{{ end }}
@@ -0,0 +1,7 @@
{{ $s := . }}
{{ $id := partial "section-id.html" $s }}
<section class="section section-{{ $s.type }}"{{ with $id }} id="{{ . }}"{{ end }} data-reveal>
<div class="wrap">
{{ partial (printf "sections/%s.html" $s.type) $s }}
</div>
</section>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,50 @@
/* Sends the site's lead forms to EspoCRM's Lead Capture. Written by
Supermarket: the form posts here instead of to [params.leads] action
directly, so its fields can be mapped onto a Lead's. */
(function () {
var mapped = { email: 'emailAddress', 'e-mail': 'emailAddress', phone: 'phoneNumber', tel: 'phoneNumber',
company: 'accountName', organization: 'accountName', organisation: 'accountName', church: 'accountName' };
function label(form, name) {
var el = form.querySelector('[name="' + name + '"]');
var l = el && el.id && form.querySelector('label[for="' + el.id + '"]');
return l ? l.childNodes[0].textContent.trim() : name;
}
window.leadPost = function (form, data) {
var lead = { firstName: null, lastName: null, emailAddress: null, accountName: null, phoneNumber: null };
var notes = [];
data.forEach(function (value, name) {
value = String(value).trim();
if (!value) return;
var key = name.toLowerCase();
if (key === 'name' || key === 'full_name' || key === 'fullname') {
var parts = value.split(/\s+/);
lead.lastName = parts.pop();
lead.firstName = parts.length ? parts.join(' ') : null;
} else if (key === 'first_name' || key === 'firstname') {
lead.firstName = value;
} else if (key === 'last_name' || key === 'lastname') {
lead.lastName = value;
} else if (mapped[key]) {
lead[mapped[key]] = value;
} else if (key === 'source') {
notes.unshift('Form: ' + value);
} else if (key === 'page') {
notes.push('Page: ' + location.origin + value);
} else {
notes.push(label(form, name) + ': ' + value);
}
});
if (!lead.lastName) lead.lastName = lead.emailAddress || 'Website visitor';
var q = new URLSearchParams(location.search);
['utm_campaign', 'utm_source', 'utm_medium', 'utm_content'].forEach(function (k) {
if (q.get(k)) notes.push(k + ': ' + q.get(k));
});
if (document.referrer) notes.push('Came from: ' + document.referrer);
lead.description = notes.join('\n') || null;
return fetch(form.action, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
body: JSON.stringify(lead)
});
};
})();
+4
View File
@@ -0,0 +1,4 @@
name = "Supermarket"
license = "Proprietary"
description = "Websites made of sections, built and kept by Supermarket."
min_version = "0.146.0"
+57
View File
@@ -0,0 +1,57 @@
// Package theme is the Hugo theme new sites are made with: federated-
// website's look and sections, made generic, with each site's brand as
// settings. Supermarket copies it into a site as themes/supermarket/.
package theme
import (
"embed"
"io/fs"
"sort"
"strconv"
"strings"
)
// Version is the theme's version, written into the site's copy
// (themes/supermarket/VERSION) so an older copy can be updated. Raise it
// whenever the files change.
const Version = 1
// Dir is where the theme goes in a site.
const Dir = "themes/supermarket"
// Name is the theme's name in hugo.toml.
const Name = "supermarket"
//go:embed all:files
var files embed.FS
// Files are the theme's files: path (inside the theme) → content,
// VERSION included.
func Files() map[string]string {
out := map[string]string{"VERSION": strconv.Itoa(Version) + "\n"}
_ = fs.WalkDir(files, "files", func(p string, d fs.DirEntry, err error) error {
if err != nil || d.IsDir() {
return err
}
raw, err := files.ReadFile(p)
if err != nil {
return err
}
out[strings.TrimPrefix(p, "files/")] = string(raw)
return nil
})
return out
}
// Paths are the theme's file paths, sorted.
func Paths() []string {
var ps []string
for p := range Files() {
ps = append(ps, p)
}
sort.Strings(ps)
return ps
}
// LeadScript is the lead forms' script (static/js/supermarket-leads.js).
func LeadScript() string { return Files()["static/js/supermarket-leads.js"] }
+144
View File
@@ -0,0 +1,144 @@
package theme
import (
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
)
const allSections = `---
title: Everything
description: Every section type.
sections:
- type: hero
eyebrow: New
title: "One **bill** for everything"
subhead: The apps your team needs.
ctas:
- { label: Start, url: /start/, style: primary }
- { label: Learn, url: "#more", style: ghost }
log:
- { tag: App, text: Read 14 tickets }
- { think: true, text: Checking }
- { done: true }
- type: text
kicker: Why
headline: Because
body: "It's **simple**."
- type: features
headline: Features
items: [{ label: Fast, body: Very }, { label: Private, body: Yours }]
- type: cards
columns: 2
items: [{ label: A, title: Card one, body: Text, link: /a/, linktext: Read }, { title: Card two, body: More, visual: true }]
- type: steps
items: [{ title: Sign up, body: Two minutes }, { title: Move in, body: We help }]
- type: checklist
items: ["Email", "Files"]
- type: split
columns: [{ title: Before, items: [Bills] }, { title: After, items: [One bill] }]
- type: stats
items: [{ value: "80%", label: saved }, { value: "24/7", label: support }]
- type: table
headers: [Them, Us]
rows: [{ label: Price, cells: ["$50", "$5"] }]
- type: faq
items: [{ q: Is it safe?, a: "Yes." }]
- type: callout
text: A note.
- type: form
headline: Ask us
subject: Contact
fields: [{ name: name, label: Name, required: true }, { name: email, label: Email, type: email, required: true }]
- type: nonsense
title: An unknown type is skipped
- type: final-cta
headline: Ready?
ctas: [{ label: Go, url: /go/ }]
---
`
func TestThemeBuilds(t *testing.T) {
hugo, err := exec.LookPath("hugo")
if err != nil {
t.Skip("no hugo")
}
site := t.TempDir()
for p, body := range Files() {
full := filepath.Join(site, Dir, p)
os.MkdirAll(filepath.Dir(full), 0o755)
os.WriteFile(full, []byte(body), 0o644)
}
cfg := `baseURL = "https://acme.example/"
title = "Acme"
theme = "supermarket"
disableKinds = ["taxonomy", "term", "RSS"]
[params]
tagline = "Widgets for everyone"
[params.brand]
primary = "#ff6600"
accent = "#0055ff"
font = "IBM Plex Sans"
[params.header]
ctas = [{ label = "Get started", url = "/start/", style = "primary" }]
[params.footer]
groups = [{ title = "Company", menu = "footer_company" }]
[params.leads]
action = "https://crm.example/api/v1/LeadCapture/k"
[[menu.main]]
name = "Pricing"
url = "/pricing/"
[[menu.footer_company]]
name = "About"
url = "/about/"
`
os.WriteFile(filepath.Join(site, "hugo.toml"), []byte(cfg), 0o644)
os.MkdirAll(filepath.Join(site, "content"), 0o755)
os.WriteFile(filepath.Join(site, "content", "_index.md"), []byte(allSections), 0o644)
os.WriteFile(filepath.Join(site, "content", "plain.md"), []byte("---\ntitle: Plain\n---\nJust **Markdown**.\n"), 0o644)
out := filepath.Join(t.TempDir(), "public")
cmd := exec.Command(hugo, "--quiet", "--destination", out)
cmd.Dir = site
if msg, err := cmd.CombinedOutput(); err != nil {
t.Fatalf("hugo: %v\n%s", err, msg)
}
home, _ := os.ReadFile(filepath.Join(out, "index.html"))
h := string(home)
for _, want := range []string{
"<title>Acme — Widgets for everyone</title>", "--lime: #ff6600", "--violet: #0055ff", `family=IBM%20Plex%20Sans:wght`, `--font: "IBM Plex Sans"`,
`<span class="brand-name">Acme</span>`, ">Pricing<", ">Get started<", "One <strong>bill</strong> for everything", "Read 14 tickets",
"section-features", "Card one", "section-steps", "section-checklist", "section-split", "section-stats", "section-table", "section-faq",
"section-callout", "section-form", `action="https://crm.example/api/v1/LeadCapture/k"`, "window.leadPost", "supermarket-leads.js",
"Ready?", ">About<", "© ",
} {
if !strings.Contains(h, want) {
t.Errorf("home lacks %q", want)
}
}
if strings.Contains(h, "An unknown type is skipped") || strings.Contains(h, "Federated") {
t.Error("an unknown section, or Federated's own text, shows")
}
plain, _ := os.ReadFile(filepath.Join(out, "plain", "index.html"))
if !strings.Contains(string(plain), "Just <strong>Markdown</strong>") {
t.Errorf("plain page: %s", plain)
}
for _, f := range []string{"css/supermarket.css", "js/supermarket-leads.js", "404.html"} {
if _, err := os.Stat(filepath.Join(out, f)); err != nil {
t.Errorf("%s missing", f)
}
}
}
func TestFiles(t *testing.T) {
fs := Files()
if fs["VERSION"] != "1\n" || !strings.Contains(fs["README.md"], "| `hero` |") || !strings.Contains(LeadScript(), "window.leadPost") {
t.Error("files")
}
for p := range fs {
if strings.Contains(fs[p], "federated.computer") {
t.Errorf("%s mentions federated.computer", p)
}
}
}