Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously an unversioned directory inside ~/src/blockninja-themes/magazine-bold. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
|
|
"git.dev.alexdunmow.com/block/core/blocks"
|
|
)
|
|
|
|
// IssueArchiveBlockMeta is the numbered list of back-issues.
|
|
var IssueArchiveBlockMeta = blocks.BlockMeta{
|
|
Key: "issue_archive",
|
|
Title: "Issue Archive",
|
|
Description: "Numbered list of back-issues driven by a bucket query.",
|
|
Source: "magazine-bold",
|
|
Category: blocks.CategoryNavigation,
|
|
}
|
|
|
|
// IssueArchiveData is what the templ component consumes.
|
|
type IssueArchiveData struct {
|
|
BucketSlug string
|
|
Limit int
|
|
}
|
|
|
|
// IssueArchiveBlock renders the issue archive list.
|
|
// content keys: bucketSlug (bucket-picker), limit (number).
|
|
//
|
|
// NOTE: bucket-row resolution is handled by the host at render-time via
|
|
// `bucket_data` injection — this block renders the scaffold and an empty
|
|
// state if the host hasn't supplied items yet.
|
|
func IssueArchiveBlock(ctx context.Context, content map[string]any) string {
|
|
data := IssueArchiveData{
|
|
BucketSlug: getString(content, "bucketSlug"),
|
|
Limit: getInt(content, "limit", 12),
|
|
}
|
|
items := getSlice(content, "items")
|
|
if items == nil {
|
|
items = getSlice(content, "bucket_data")
|
|
}
|
|
var buf bytes.Buffer
|
|
_ = issueArchiveComponent(data, items).Render(ctx, &buf)
|
|
return buf.String()
|
|
}
|