themes-cyberpunk/code_neon.go
Alex Dunmow 313ebaf296 initial: theme plugin cyberpunk
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>
2026-06-06 14:11:25 +08:00

40 lines
1012 B
Go

package main
import (
"bytes"
"context"
"git.dev.alexdunmow.com/block/core/blocks"
)
// CodeNeonMeta defines metadata for the cyberpunk:code_neon block.
var CodeNeonMeta = blocks.BlockMeta{
Key: "code_neon",
Title: "Code Block",
Description: "Server-rendered code block with neon edge and optional copy button",
Category: blocks.CategoryContent,
Source: "cyberpunk",
}
// CodeNeonData is the typed view of the code_neon content map.
type CodeNeonData struct {
Language string
Code string
Copy bool
}
// CodeNeonBlock renders the code_neon block.
//
// Content shape:
// {language:"bash"|"go"|..., code, copy: bool|"on"|"off"}
func CodeNeonBlock(ctx context.Context, content map[string]any) string {
data := CodeNeonData{
Language: getStringWithDefault(content, "language", "text"),
Code: getString(content, "code"),
Copy: getBool(content, "copy", true),
}
var buf bytes.Buffer
_ = codeNeonComponent(data).Render(ctx, &buf)
return buf.String()
}