themes-editorial/pullquote.go
Alex Dunmow 1d9a4c8ce6 initial: theme plugin editorial
Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously
an unversioned directory inside ~/src/blockninja-themes/editorial.

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

49 lines
1.2 KiB
Go

package main
import (
"bytes"
"context"
"git.dev.alexdunmow.com/block/core/blocks"
)
// PullquoteBlockMeta describes the Editorial pull-quote block: a large oxblood
// Playfair italic block quote with optional attribution.
// Registered as "editorial:pullquote" at runtime.
var PullquoteBlockMeta = blocks.BlockMeta{
Key: "pullquote",
Title: "Pull Quote",
Description: "Large oxblood pull quote in Playfair italic",
Source: "editorial",
Category: blocks.CategoryTheme,
}
// PullquoteData carries parsed pull-quote content.
type PullquoteData struct {
Quote string // rich-text payload, trusted upstream
Attribution string
}
// PullquoteBlock renders the pull quote.
//
// Content shape:
//
// {
// "quote": "<p>The reform was always going to be quiet.</p>",
// "attribution": "— The Editor"
// }
func PullquoteBlock(ctx context.Context, content map[string]any) string {
data := PullquoteData{
Quote: getString(content, "quote"),
Attribution: getString(content, "attribution"),
}
if data.Quote == "" {
return ""
}
var buf bytes.Buffer
_ = pullquoteComponent(data).Render(ctx, &buf)
return buf.String()
}