Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously an unversioned directory inside ~/src/blockninja-themes/noir. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
|
|
"git.dev.alexdunmow.com/block/core/blocks"
|
|
)
|
|
|
|
// CaseStudyBlockMeta defines the Noir long-form project case study block.
|
|
var CaseStudyBlockMeta = blocks.BlockMeta{
|
|
Key: "case_study",
|
|
Title: "Project Case Study",
|
|
Description: "Long-form project spread with sticky meta rail and image-led prose.",
|
|
Source: "noir",
|
|
Category: blocks.CategoryLayout,
|
|
}
|
|
|
|
// CaseStudyBlock renders a project case study.
|
|
// Content shape: {"title":"...","client":"...","year":2025,"credits":["...","..."],"images":["...","..."]}
|
|
func CaseStudyBlock(ctx context.Context, content map[string]any) string {
|
|
data := CaseStudyData{
|
|
Title: getString(content, "title"),
|
|
Client: getString(content, "client"),
|
|
Year: getInt(content, "year", 0),
|
|
Credits: getStringSlice(content, "credits"),
|
|
}
|
|
|
|
for _, img := range getStringSlice(content, "images") {
|
|
if img == "" {
|
|
continue
|
|
}
|
|
data.Images = append(data.Images, blocks.ResolveMediaPath(img))
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
_ = caseStudyComponent(data).Render(ctx, &buf)
|
|
return buf.String()
|
|
}
|
|
|
|
// CaseStudyData holds the parsed view-model for the case study block.
|
|
type CaseStudyData struct {
|
|
Title string
|
|
Client string
|
|
Year int
|
|
Credits []string
|
|
Images []string
|
|
}
|