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

57 lines
1.3 KiB
Go

package main
import (
"bytes"
"context"
"git.dev.alexdunmow.com/block/core/blocks"
)
// StatPairMeta is the block metadata for corporate-modernist:stat_pair.
var StatPairMeta = blocks.BlockMeta{
Key: "stat_pair",
Title: "Stat Pair",
Description: "Row of mono-numeral statistics separated by a hairline rule.",
Source: "corporate-modernist",
Category: blocks.CategoryContent,
}
// StatPairItem represents a single stat entry.
type StatPairItem struct {
Figure string
Label string
Source string
}
// StatPairData carries the parsed content for the stat_pair block.
type StatPairData struct {
Title string
Stats []StatPairItem
}
// StatPairBlock renders the stat_pair block.
func StatPairBlock(ctx context.Context, content map[string]any) string {
rawStats := getSlice(content, "stats")
stats := make([]StatPairItem, 0, len(rawStats))
for _, s := range rawStats {
figure := getString(s, "figure")
if figure == "" {
continue
}
stats = append(stats, StatPairItem{
Figure: figure,
Label: getString(s, "label"),
Source: getString(s, "source"),
})
}
data := StatPairData{
Title: getString(content, "title"),
Stats: stats,
}
var buf bytes.Buffer
_ = statPairComponent(data).Render(ctx, &buf)
return buf.String()
}