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() }