themes-editorial/image_override.go
Alex Dunmow 1d9a4c8ce6 initial: theme plugin editorial
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>
2026-06-06 14:11:28 +08:00

27 lines
724 B
Go

package main
import (
"bytes"
"context"
)
// EditorialImageBlock overrides the built-in `image` block for the editorial
// template. The image is wrapped in a <figure>; the caption is rendered as
// Source Serif italic 14px, preceded by a 1px hairline rule (UAT §13.12).
//
// Content shape: { "src", "alt", "caption" }.
func EditorialImageBlock(ctx context.Context, content map[string]any) string {
src := getString(content, "src")
alt := getString(content, "alt")
caption := getString(content, "caption")
if src == "" {
// Match built-in fallback: render nothing for an empty image.
return ""
}
var buf bytes.Buffer
_ = editorialImageComponent(src, alt, caption).Render(ctx, &buf)
return buf.String()
}