themes-y2k/merch_card.go
Alex Dunmow 49f9c90589 initial: theme plugin y2k
Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously
an unversioned directory inside ~/src/blockninja-themes/y2k.

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

42 lines
1.0 KiB
Go

package main
import (
"bytes"
"context"
"git.dev.alexdunmow.com/block/core/blocks"
)
// MerchCardBlockMeta declares the merch product card block.
var MerchCardBlockMeta = blocks.BlockMeta{
Key: "merch_card",
Title: "Merch Card",
Description: "Plastic-bevel product card with a corner sticker badge.",
Source: "y2k",
Category: blocks.CategoryContent,
}
// MerchCardBlock renders the merch card.
// Content: {title, price, image, buyHref, sticker}
func MerchCardBlock(ctx context.Context, content map[string]any) string {
data := MerchCardData{
Title: getString(content, "title"),
Price: getString(content, "price"),
Image: getString(content, "image"),
BuyHref: getString(content, "buyHref"),
Sticker: getString(content, "sticker"),
}
var buf bytes.Buffer
_ = merchCardComponent(data).Render(ctx, &buf)
return buf.String()
}
// MerchCardData is the typed shape for the templ component.
type MerchCardData struct {
Title string
Price string
Image string
BuyHref string
Sticker string
}