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{ "