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>
59 lines
1.3 KiB
Go
59 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
|
|
"git.dev.alexdunmow.com/block/core/blocks"
|
|
)
|
|
|
|
// CTAStripMeta is the block metadata for corporate-modernist:cta_strip.
|
|
var CTAStripMeta = blocks.BlockMeta{
|
|
Key: "cta_strip",
|
|
Title: "CTA Strip",
|
|
Description: "Single-line accent strip with a headline and a primary call to action.",
|
|
Source: "corporate-modernist",
|
|
Category: blocks.CategoryLayout,
|
|
}
|
|
|
|
// CTAStripData carries the parsed content for the cta_strip block.
|
|
type CTAStripData struct {
|
|
Headline string
|
|
CTALabel string
|
|
CTAHref string
|
|
HasCTA bool
|
|
Variant string
|
|
}
|
|
|
|
// CTAStripBlock renders the cta_strip block.
|
|
func CTAStripBlock(ctx context.Context, content map[string]any) string {
|
|
primary := getNested(content, "primaryCta")
|
|
ctaLabel := ""
|
|
ctaHref := ""
|
|
hasCTA := false
|
|
if primary != nil {
|
|
ctaLabel = linkLabel(primary, "")
|
|
ctaHref = linkHref(primary)
|
|
if ctaLabel != "" || ctaHref != "#" {
|
|
hasCTA = true
|
|
}
|
|
}
|
|
|
|
variant := getString(content, "variant")
|
|
if variant == "" {
|
|
variant = "book-call"
|
|
}
|
|
|
|
data := CTAStripData{
|
|
Headline: getString(content, "headline"),
|
|
CTALabel: ctaLabel,
|
|
CTAHref: ctaHref,
|
|
HasCTA: hasCTA,
|
|
Variant: variant,
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
_ = ctaStripComponent(data).Render(ctx, &buf)
|
|
return buf.String()
|
|
}
|