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

59 lines
1.4 KiB
Go

package main
import (
"bytes"
"context"
"git.dev.alexdunmow.com/block/core/blocks"
)
// FooterBlockMeta defines metadata for the instrument footer block.
var FooterBlockMeta = blocks.BlockMeta{
Key: "footer",
Title: "Instrument Footer",
Description: "Hairline-rule footer with callsign, optional signup, and link list.",
Source: "scifi-clean",
Category: blocks.CategoryLayout,
}
// FooterLink is one footer link entry.
type FooterLink struct {
Text string
URL string
}
// FooterData drives the templ render.
type FooterData struct {
ShowSignup bool
Callsign string
Links []FooterLink
}
// FooterBlock renders the footer.
// Content shape: {"showSignup": false, "callsign": "SCF-CLN", "links": [{"text": "...", "url": "..."}]}
func FooterBlock(ctx context.Context, content map[string]any) string {
data := FooterData{
ShowSignup: getBool(content, "showSignup", false),
Callsign: getStringDefault(content, "callsign", "SCF-CLN"),
}
for _, raw := range getSlice(content, "links") {
data.Links = append(data.Links, FooterLink{
Text: getString(raw, "text"),
URL: getString(raw, "url"),
})
}
var buf bytes.Buffer
_ = footerComponent(data).Render(ctx, &buf)
return buf.String()
}
// safeHref returns # for blank URLs so the templ.SafeURL helper has something to chew on.
func safeHref(u string) string {
if u == "" {
return "#"
}
return u
}