package main import ( "bytes" "context" "git.dev.alexdunmow.com/block/core/blocks" ) // HeroStatementMeta is the block metadata for corporate-modernist:hero_statement. var HeroStatementMeta = blocks.BlockMeta{ Key: "hero_statement", Title: "Hero Statement", Description: "Restrained hero with eyebrow, headline, lede, and a single accent CTA.", Source: "corporate-modernist", Category: blocks.CategoryLayout, } // HeroStatementCTA captures a single label/href pair for hero CTAs. type HeroStatementCTA struct { Label string Href string } // HeroStatementData carries the parsed content for the hero_statement block. type HeroStatementData struct { Eyebrow string Headline string Lede string PrimaryCTA HeroStatementCTA HasPrimary bool SecondaryCTA HeroStatementCTA HasSecondary bool } // HeroStatementBlock renders the hero_statement block. func HeroStatementBlock(ctx context.Context, content map[string]any) string { primary := getNested(content, "primaryCta") secondary := getNested(content, "secondaryCta") data := HeroStatementData{ Eyebrow: getString(content, "eyebrow"), Headline: getString(content, "headline"), Lede: getString(content, "lede"), } if primary != nil { label := linkLabel(primary, "") href := linkHref(primary) if label != "" || href != "#" { data.PrimaryCTA = HeroStatementCTA{Label: label, Href: href} data.HasPrimary = true } } if secondary != nil { label := linkLabel(secondary, "") href := linkHref(secondary) if label != "" || href != "#" { data.SecondaryCTA = HeroStatementCTA{Label: label, Href: href} data.HasSecondary = true } } var buf bytes.Buffer _ = heroStatementComponent(data).Render(ctx, &buf) return buf.String() }