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>
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
|
|
"git.dev.alexdunmow.com/block/core/blocks"
|
|
)
|
|
|
|
// TracklistBlockMeta declares the CD-jewel-case tracklist block.
|
|
var TracklistBlockMeta = blocks.BlockMeta{
|
|
Key: "tracklist",
|
|
Title: "Tracklist",
|
|
Description: "Tabular tracklist styled like a CD jewel case insert.",
|
|
Source: "y2k",
|
|
Category: blocks.CategoryContent,
|
|
}
|
|
|
|
// TracklistBlock renders the tracklist.
|
|
// Content: {tracks[{title, duration, url}]}
|
|
func TracklistBlock(ctx context.Context, content map[string]any) string {
|
|
raw := getSlice(content, "tracks")
|
|
tracks := make([]TrackRow, 0, len(raw))
|
|
for _, r := range raw {
|
|
tracks = append(tracks, TrackRow{
|
|
Title: getString(r, "title"),
|
|
Duration: getString(r, "duration"),
|
|
URL: getString(r, "url"),
|
|
})
|
|
}
|
|
var buf bytes.Buffer
|
|
_ = tracklistComponent(TracklistData{Tracks: tracks}).Render(ctx, &buf)
|
|
return buf.String()
|
|
}
|
|
|
|
// TracklistData is the typed shape for the templ component.
|
|
type TracklistData struct {
|
|
Tracks []TrackRow
|
|
}
|
|
|
|
// TrackRow is a single tracklist row.
|
|
type TrackRow struct {
|
|
Title string
|
|
Duration string
|
|
URL string
|
|
}
|