themes-noir/image_pair.go
Alex Dunmow 1bebbea5ad initial: theme plugin noir
Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously
an unversioned directory inside ~/src/blockninja-themes/noir.

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

39 lines
1014 B
Go

package main
import (
"bytes"
"context"
"git.dev.alexdunmow.com/block/core/blocks"
)
// ImagePairBlockMeta defines the Noir diptych block.
var ImagePairBlockMeta = blocks.BlockMeta{
Key: "image_pair",
Title: "Image Pair",
Description: "50/50 photograph diptych with a shared caption beneath both images.",
Source: "noir",
Category: blocks.CategoryContent,
}
// ImagePairBlock renders a two-photograph diptych.
// Content shape: {"left":"...","right":"...","caption":"..."}
func ImagePairBlock(ctx context.Context, content map[string]any) string {
data := ImagePairData{
Left: blocks.ResolveMediaPath(getString(content, "left")),
Right: blocks.ResolveMediaPath(getString(content, "right")),
Caption: getString(content, "caption"),
}
var buf bytes.Buffer
_ = imagePairComponent(data).Render(ctx, &buf)
return buf.String()
}
// ImagePairData holds the parsed view-model for the diptych.
type ImagePairData struct {
Left string
Right string
Caption string
}