Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously an unversioned directory inside ~/src/blockninja-themes/brutalist. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
|
|
"git.dev.alexdunmow.com/block/core/blocks"
|
|
)
|
|
|
|
// ProjectLedgerBlockMeta defines the Project Ledger block.
|
|
var ProjectLedgerBlockMeta = blocks.BlockMeta{
|
|
Key: "project_ledger",
|
|
Title: "Project Ledger",
|
|
Description: "Ordered project list on a 12-col grid: number / year / client / role / arrow",
|
|
Category: blocks.CategoryContent,
|
|
Source: "brutalist",
|
|
}
|
|
|
|
// ProjectLedgerRow is one row in the ledger.
|
|
type ProjectLedgerRow struct {
|
|
No string
|
|
Year string
|
|
Client string
|
|
Role string
|
|
Link string
|
|
}
|
|
|
|
// ProjectLedgerData carries data for the ledger component.
|
|
type ProjectLedgerData struct {
|
|
Rows []ProjectLedgerRow
|
|
}
|
|
|
|
// ProjectLedgerBlock renders the project ledger.
|
|
// Content: {"rows": [{"no":"01","year":"2024","client":"...","role":"...","link":"..."}]}
|
|
func ProjectLedgerBlock(ctx context.Context, content map[string]any) string {
|
|
raw := getSlice(content, "rows")
|
|
rows := make([]ProjectLedgerRow, 0, len(raw))
|
|
for _, item := range raw {
|
|
rows = append(rows, ProjectLedgerRow{
|
|
No: getString(item, "no"),
|
|
Year: getString(item, "year"),
|
|
Client: getString(item, "client"),
|
|
Role: getString(item, "role"),
|
|
Link: getString(item, "link"),
|
|
})
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
_ = projectLedgerComponent(ProjectLedgerData{Rows: rows}).Render(ctx, &buf)
|
|
return buf.String()
|
|
}
|