42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
|
|
"git.dev.alexdunmow.com/block/core/blocks"
|
|
)
|
|
|
|
// HeroBlockMeta defines metadata for the hero section block.
|
|
var HeroBlockMeta = blocks.BlockMeta{
|
|
Key: "hero",
|
|
Title: "Hero Section",
|
|
Description: "Large hero section with headline and optional CTA",
|
|
Source: "gotham",
|
|
}
|
|
|
|
// HeroBlock renders a hero section.
|
|
// Content expects: {"headline": "...", "subheadline": "...", "background_url": "...", "cta_text": "...", "cta_url": "..."}
|
|
func HeroBlock(ctx context.Context, content map[string]any, _ []string) string {
|
|
data := HeroData{
|
|
Headline: getString(content, "headline"),
|
|
Subheadline: getString(content, "subheadline"),
|
|
BackgroundURL: getString(content, "background_url"),
|
|
CTAText: getString(content, "cta_text"),
|
|
CTAURL: getString(content, "cta_url"),
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
_ = heroComponent(data).Render(ctx, &buf)
|
|
return buf.String()
|
|
}
|
|
|
|
// HeroData contains data for the hero component.
|
|
type HeroData struct {
|
|
Headline string
|
|
Subheadline string
|
|
BackgroundURL string
|
|
CTAText string
|
|
CTAURL string
|
|
}
|