Alex Dunmow 4713787bbd initial: theme plugin corporate-modernist
Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously
an unversioned directory inside ~/src/blockninja-themes/corporate-modernist.

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

76 lines
1.7 KiB
Go

package main
import (
"bytes"
"context"
"git.dev.alexdunmow.com/block/core/blocks"
)
// FooterMeta is the block metadata for corporate-modernist:footer.
var FooterMeta = blocks.BlockMeta{
Key: "footer",
Title: "Footer",
Description: "Multi-column footer with legal line; compact and full variants.",
Source: "corporate-modernist",
Category: blocks.CategoryNavigation,
}
// FooterLink represents a single link in a footer column.
type FooterLink struct {
Label string
Href string
}
// FooterColumn is a single labelled column of footer links.
type FooterColumn struct {
Title string
Links []FooterLink
}
// FooterData carries the parsed content for the footer block.
type FooterData struct {
Columns []FooterColumn
LegalLine string
ShowLegal bool
Variant string
}
// FooterBlock renders the footer block.
func FooterBlock(ctx context.Context, content map[string]any) string {
rawColumns := getSlice(content, "columns")
columns := make([]FooterColumn, 0, len(rawColumns))
for _, c := range rawColumns {
rawLinks := getSlice(c, "links")
links := make([]FooterLink, 0, len(rawLinks))
for _, l := range rawLinks {
label := linkLabel(l, "")
href := linkHref(l)
if label == "" && href == "#" {
continue
}
links = append(links, FooterLink{Label: label, Href: href})
}
columns = append(columns, FooterColumn{
Title: getString(c, "title"),
Links: links,
})
}
variant := getString(content, "variant")
if variant == "" {
variant = "compact"
}
data := FooterData{
Columns: columns,
LegalLine: getString(content, "legalLine"),
ShowLegal: getBool(content, "showLegal", true),
Variant: variant,
}
var buf bytes.Buffer
_ = footerComponent(data).Render(ctx, &buf)
return buf.String()
}