Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously an unversioned directory inside ~/src/blockninja-themes/corporate-modernist. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
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()
|
|
}
|