package main import ( "bytes" "context" "git.dev.alexdunmow.com/block/core/blocks" ) // CaptionImageBlockMeta defines the Captioned Image block. var CaptionImageBlockMeta = blocks.BlockMeta{ Key: "caption_image", Title: "Captioned Image", Description: "Image with 11px mono caption in the left gutter", Category: blocks.CategoryContent, Source: "brutalist", } // CaptionImageData carries data for the caption-image component. type CaptionImageData struct { ImageURL string Caption string FigureNumber string } // CaptionImageBlock renders the captioned image. // Content: {"image": "media:", "caption": "...", "figureNumber": "Fig. 01"} func CaptionImageBlock(ctx context.Context, content map[string]any) string { img := getString(content, "image") resolvedImage := "" if img != "" { resolvedImage = blocks.ResolveMediaPath(img) } data := CaptionImageData{ ImageURL: resolvedImage, Caption: getString(content, "caption"), FigureNumber: getString(content, "figureNumber"), } var buf bytes.Buffer _ = captionImageComponent(data).Render(ctx, &buf) return buf.String() }