Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously an unversioned directory inside ~/src/blockninja-themes/kindergarten. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
|
|
"git.dev.alexdunmow.com/block/core/blocks"
|
|
)
|
|
|
|
// GalleryOfArtBlockMeta defines metadata for the gallery of art block.
|
|
var GalleryOfArtBlockMeta = blocks.BlockMeta{
|
|
Key: "gallery_of_art",
|
|
Title: "Gallery of Art",
|
|
Description: "Polaroid-style grid for kid artwork.",
|
|
Category: blocks.CategoryContent,
|
|
Source: "kindergarten",
|
|
}
|
|
|
|
// GalleryArt represents a single artwork entry.
|
|
type GalleryArt struct {
|
|
Image string
|
|
ChildName string
|
|
Age int
|
|
}
|
|
|
|
// GalleryData is the renderer input.
|
|
type GalleryData struct {
|
|
Title string
|
|
ShowChildName bool
|
|
Items []GalleryArt
|
|
}
|
|
|
|
// GalleryOfArtBlock renders the polaroid grid.
|
|
// Content shape: {title,showChildName,items:[{image,childName,age}]}.
|
|
//
|
|
// Privacy: when showChildName=false, no child names are rendered.
|
|
func GalleryOfArtBlock(ctx context.Context, content map[string]any) string {
|
|
raw := getSlice(content, "items")
|
|
items := make([]GalleryArt, 0, len(raw))
|
|
for _, m := range raw {
|
|
items = append(items, GalleryArt{
|
|
Image: getString(m, "image"),
|
|
ChildName: getString(m, "childName"),
|
|
Age: getInt(m, "age", 0),
|
|
})
|
|
}
|
|
|
|
data := GalleryData{
|
|
Title: getString(content, "title"),
|
|
ShowChildName: getBool(content, "showChildName", true),
|
|
Items: items,
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
_ = galleryOfArtComponent(data).Render(ctx, &buf)
|
|
return buf.String()
|
|
}
|