Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously an unversioned directory inside ~/src/blockninja-themes/scifi-clean. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
|
|
"git.dev.alexdunmow.com/block/core/blocks"
|
|
)
|
|
|
|
// TechSpecBlockMeta defines metadata for the tech-spec table block.
|
|
var TechSpecBlockMeta = blocks.BlockMeta{
|
|
Key: "tech_spec",
|
|
Title: "Tech Spec Table",
|
|
Description: "Specification table with right-aligned mono numerals and hairline rows.",
|
|
Source: "scifi-clean",
|
|
Category: blocks.CategoryContent,
|
|
}
|
|
|
|
// TechSpecRow is one label/value/unit triple.
|
|
type TechSpecRow struct {
|
|
Label string
|
|
Value string
|
|
Unit string
|
|
}
|
|
|
|
// TechSpecData drives the templ render.
|
|
type TechSpecData struct {
|
|
Caption string
|
|
Rows []TechSpecRow
|
|
}
|
|
|
|
// TechSpecBlock renders the tech-spec block.
|
|
// Content shape: {"caption": "...", "rows": [{"label": "...", "value": "...", "unit": "..."}]}
|
|
func TechSpecBlock(ctx context.Context, content map[string]any) string {
|
|
data := TechSpecData{
|
|
Caption: getString(content, "caption"),
|
|
}
|
|
|
|
for _, raw := range getSlice(content, "rows") {
|
|
data.Rows = append(data.Rows, TechSpecRow{
|
|
Label: getString(raw, "label"),
|
|
Value: getString(raw, "value"),
|
|
Unit: getString(raw, "unit"),
|
|
})
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
_ = techSpecComponent(data).Render(ctx, &buf)
|
|
return buf.String()
|
|
}
|