Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously an unversioned directory inside ~/src/blockninja-themes/cyberpunk. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
56 lines
1.5 KiB
Go
56 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
|
|
"git.dev.alexdunmow.com/block/core/blocks"
|
|
)
|
|
|
|
// HeroGlitchMeta defines metadata for the cyberpunk glitch hero block.
|
|
var HeroGlitchMeta = blocks.BlockMeta{
|
|
Key: "hero_glitch",
|
|
Title: "Glitch Hero",
|
|
Description: "RGB-split H1, neon CTA, optional scanline overlay toggle",
|
|
Category: blocks.CategoryLayout,
|
|
Source: "cyberpunk",
|
|
}
|
|
|
|
// HeroGlitchData is the typed view of the hero_glitch content map.
|
|
type HeroGlitchData struct {
|
|
Eyebrow string
|
|
Headline string
|
|
Sub string
|
|
CTA Link
|
|
SecondaryCTA Link
|
|
Scanlines bool
|
|
}
|
|
|
|
// HeroGlitchBlock renders the hero_glitch block.
|
|
//
|
|
// Content shape (matches schemas/hero_glitch.schema.json):
|
|
// {eyebrow, headline, sub, cta:{label,href}, secondaryCta:{label,href}, scanlines:"on"|"off"}
|
|
func HeroGlitchBlock(ctx context.Context, content map[string]any) string {
|
|
data := HeroGlitchData{
|
|
Eyebrow: getString(content, "eyebrow"),
|
|
Headline: getStringWithDefault(content, "headline", "// hero headline"),
|
|
Sub: getString(content, "sub"),
|
|
CTA: getLink(content, "cta"),
|
|
SecondaryCTA: getLink(content, "secondaryCta"),
|
|
Scanlines: parseScanlines(content),
|
|
}
|
|
var buf bytes.Buffer
|
|
_ = heroGlitchComponent(data).Render(ctx, &buf)
|
|
return buf.String()
|
|
}
|
|
|
|
func parseScanlines(content map[string]any) bool {
|
|
if v, ok := content["scanlines"].(string); ok {
|
|
return v == "on" || v == "true"
|
|
}
|
|
if v, ok := content["scanlines"].(bool); ok {
|
|
return v
|
|
}
|
|
return true
|
|
}
|