themes-terminal/ascii_header.go
Alex Dunmow 0a9b177f7c initial: theme plugin terminal
Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously
an unversioned directory inside ~/src/blockninja-themes/terminal.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 14:11:44 +08:00

47 lines
1.2 KiB
Go

package main
import (
"bytes"
"context"
"git.dev.alexdunmow.com/block/core/blocks"
)
// AsciiHeaderBlockMeta defines metadata for the TTY ascii header block.
var AsciiHeaderBlockMeta = blocks.BlockMeta{
Key: "ascii_header",
Title: "ASCII Header",
Description: "Figlet-style TTY banner with a shell prompt line",
Source: "terminal",
Category: blocks.CategoryLayout,
}
// AsciiHeaderData is the parsed content for the ascii_header block.
type AsciiHeaderData struct {
Title string
Prompt string
AsciiArt string
}
// AsciiHeaderBlock renders the TTY banner.
// Content shape: {title, prompt, asciiArt}.
func AsciiHeaderBlock(ctx context.Context, content map[string]any) string {
data := AsciiHeaderData{
Title: getString(content, "title"),
Prompt: getString(content, "prompt"),
AsciiArt: getString(content, "asciiArt"),
}
// Sensible empty-state defaults so unconfigured blocks still render
// something terminal-flavoured rather than an empty surface.
if data.Title == "" && data.AsciiArt == "" {
data.Title = "~"
}
if data.Prompt == "" {
data.Prompt = "$ "
}
var buf bytes.Buffer
_ = asciiHeaderComponent(data).Render(ctx, &buf)
return buf.String()
}