Alex Dunmow 9fbedf5ba1 initial: theme plugin art-deco
Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously
an unversioned directory inside ~/src/blockninja-themes/art-deco.

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

53 lines
1.2 KiB
Go

package main
import (
"bytes"
"context"
"git.dev.alexdunmow.com/block/core/blocks"
)
// MenuBlockMeta defines the tasting menu block.
var MenuBlockMeta = blocks.BlockMeta{
Key: "menu",
Title: "Tasting Menu",
Description: "Symmetric two-column menu card listing courses with description and price.",
Source: "art-deco",
}
// MenuCourse is a single course on the menu.
type MenuCourse struct {
Name string
Description string
Price string
}
// MenuData is the typed view for the menu component.
type MenuData struct {
Title string
Courses []MenuCourse
}
// MenuBlock renders a tasting menu card.
// Content: {"title": "...", "courses": [{"name": "...", "description": "...", "price": "..."}]}
func MenuBlock(ctx context.Context, content map[string]any) string {
items := getSlice(content, "courses")
courses := make([]MenuCourse, 0, len(items))
for _, item := range items {
courses = append(courses, MenuCourse{
Name: getString(item, "name"),
Description: getString(item, "description"),
Price: getString(item, "price"),
})
}
data := MenuData{
Title: getString(content, "title"),
Courses: courses,
}
var buf bytes.Buffer
_ = menuComponent(data).Render(ctx, &buf)
return buf.String()
}