themes-scifi-clean/schematic_hero.go
Alex Dunmow 96b87b3e81 initial: theme plugin scifi-clean
Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously
an unversioned directory inside ~/src/blockninja-themes/scifi-clean.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 14:11:43 +08:00

56 lines
1.6 KiB
Go

package main
import (
"bytes"
"context"
"git.dev.alexdunmow.com/block/core/blocks"
)
// SchematicHeroBlockMeta defines metadata for the landing hero.
var SchematicHeroBlockMeta = blocks.BlockMeta{
Key: "schematic_hero",
Title: "Schematic Hero",
Description: "Landing hero with a large display title over a blueprint image and dual CTAs.",
Source: "scifi-clean",
Category: blocks.CategoryLayout,
}
// SchematicCTA is a single call-to-action link.
type SchematicCTA struct {
Text string
Href string
}
// SchematicHeroData drives the templ render.
type SchematicHeroData struct {
Title string
Kicker string
Image string
PrimaryCTA SchematicCTA
SecondaryCTA SchematicCTA
}
// SchematicHeroBlock renders the landing hero.
// Content shape: {"title": "...", "kicker": "...", "image": "media:...",
// "primaryCta": {"text": "...", "href": "..."},
// "secondaryCta": {"text": "...", "href": "..."}}
func SchematicHeroBlock(ctx context.Context, content map[string]any) string {
data := SchematicHeroData{
Title: getString(content, "title"),
Kicker: getString(content, "kicker"),
Image: blocks.ResolveMediaPath(getString(content, "image")),
}
if m := getMap(content, "primaryCta"); m != nil {
data.PrimaryCTA = SchematicCTA{Text: getString(m, "text"), Href: getString(m, "href")}
}
if m := getMap(content, "secondaryCta"); m != nil {
data.SecondaryCTA = SchematicCTA{Text: getString(m, "text"), Href: getString(m, "href")}
}
var buf bytes.Buffer
_ = schematicHeroComponent(data).Render(ctx, &buf)
return buf.String()
}