package main import ( "bytes" "context" "git.dev.alexdunmow.com/block/core/blocks" ) // MarginaliaBlockMeta describes the Editorial marginalia rail block: a list of // italic notes anchored to in-body markers. At narrow viewports the rail // collapses to inline asides via CSS. // Registered as "editorial:marginalia" at runtime. var MarginaliaBlockMeta = blocks.BlockMeta{ Key: "marginalia", Title: "Marginalia Rail", Description: "Right-rail italic notes for longform articles", Source: "editorial", Category: blocks.CategoryTheme, } // MarginaliaNote is one row in the marginalia rail. type MarginaliaNote struct { Note string // rich-text payload Anchor string } // MarginaliaData carries parsed marginalia content. type MarginaliaData struct { Notes []MarginaliaNote } // MarginaliaBlock renders the marginalia rail. // // Content shape: // // { // "items": [ // { "note": "

Sourced from the 2024 audit.

", "anchor": "ΒΆ3" } // ] // } func MarginaliaBlock(ctx context.Context, content map[string]any) string { items := getSlice(content, "items") notes := make([]MarginaliaNote, 0, len(items)) for _, item := range items { notes = append(notes, MarginaliaNote{ Note: getString(item, "note"), Anchor: getString(item, "anchor"), }) } data := MarginaliaData{Notes: notes} var buf bytes.Buffer _ = marginaliaComponent(data).Render(ctx, &buf) return buf.String() }