Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously an unversioned directory inside ~/src/blockninja-themes/editorial. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
|
|
"git.dev.alexdunmow.com/block/core/blocks"
|
|
)
|
|
|
|
// SectionLabelBlockMeta describes the Editorial section-label block: an
|
|
// uppercase / small-caps label followed by an optional hairline divider.
|
|
// Registered as "editorial:section_label" at runtime.
|
|
var SectionLabelBlockMeta = blocks.BlockMeta{
|
|
Key: "section_label",
|
|
Title: "Section Label",
|
|
Description: "Small-caps section label with optional hairline divider",
|
|
Source: "editorial",
|
|
Category: blocks.CategoryTheme,
|
|
}
|
|
|
|
// SectionLabelData carries parsed section-label content.
|
|
type SectionLabelData struct {
|
|
Label string
|
|
Divider bool
|
|
}
|
|
|
|
// SectionLabelBlock renders the section label.
|
|
//
|
|
// Content shape:
|
|
//
|
|
// { "label": "Politics", "divider": "true" }
|
|
func SectionLabelBlock(ctx context.Context, content map[string]any) string {
|
|
data := SectionLabelData{
|
|
Label: getString(content, "label"),
|
|
Divider: getBool(content, "divider", true),
|
|
}
|
|
|
|
if data.Label == "" {
|
|
return ""
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
_ = sectionLabelComponent(data).Render(ctx, &buf)
|
|
return buf.String()
|
|
}
|