Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously an unversioned directory inside ~/src/blockninja-themes/earthen. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
70 lines
1.7 KiB
Go
70 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
|
|
"git.dev.alexdunmow.com/block/core/blocks"
|
|
)
|
|
|
|
// FooterBlockMeta defines metadata for the earthen footer block.
|
|
var FooterBlockMeta = blocks.BlockMeta{
|
|
Key: "footer",
|
|
Title: "Site Footer",
|
|
Description: "Cream-on-moss footer with optional newsletter and column links",
|
|
Source: "earthen",
|
|
Category: blocks.CategoryNavigation,
|
|
}
|
|
|
|
// FooterBlock renders the earthen footer block.
|
|
// Content shape: {showNewsletter, tagline, columns:[{title,links:[{text,url}]}]}
|
|
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 {
|
|
links = append(links, FooterLink{
|
|
Text: getString(l, "text"),
|
|
URL: getString(l, "url"),
|
|
})
|
|
}
|
|
columns = append(columns, FooterColumn{
|
|
Title: getString(c, "title"),
|
|
Links: links,
|
|
})
|
|
}
|
|
|
|
data := FooterData{
|
|
ShowNewsletter: getBool(content, "showNewsletter", false),
|
|
Tagline: getString(content, "tagline"),
|
|
Columns: columns,
|
|
Empty: len(content) == 0,
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
_ = footerComponent(data).Render(ctx, &buf)
|
|
return buf.String()
|
|
}
|
|
|
|
// FooterData contains data for the footer component.
|
|
type FooterData struct {
|
|
ShowNewsletter bool
|
|
Tagline string
|
|
Columns []FooterColumn
|
|
Empty bool
|
|
}
|
|
|
|
// FooterColumn is a single link column in the footer.
|
|
type FooterColumn struct {
|
|
Title string
|
|
Links []FooterLink
|
|
}
|
|
|
|
// FooterLink is a single link in a footer column.
|
|
type FooterLink struct {
|
|
Text string
|
|
URL string
|
|
}
|