Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously an unversioned directory inside ~/src/blockninja-themes/corporate-modernist. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
|
|
"git.dev.alexdunmow.com/block/core/blocks"
|
|
)
|
|
|
|
// CaseStudyCardMeta is the block metadata for corporate-modernist:case_study_card.
|
|
var CaseStudyCardMeta = blocks.BlockMeta{
|
|
Key: "case_study_card",
|
|
Title: "Case Study Card",
|
|
Description: "Single case study card with a big tabular metric.",
|
|
Source: "corporate-modernist",
|
|
Category: blocks.CategoryContent,
|
|
}
|
|
|
|
// CaseStudyCardData carries the parsed content for the case_study_card block.
|
|
type CaseStudyCardData struct {
|
|
Client string
|
|
Metric string
|
|
Label string
|
|
Summary string
|
|
HrefLabel string
|
|
Href string
|
|
HasLink bool
|
|
}
|
|
|
|
// CaseStudyCardBlock renders the case_study_card block.
|
|
func CaseStudyCardBlock(ctx context.Context, content map[string]any) string {
|
|
link := getNested(content, "href")
|
|
hrefLabel := ""
|
|
href := ""
|
|
hasLink := false
|
|
if link != nil {
|
|
hrefLabel = linkLabel(link, "")
|
|
href = linkHref(link)
|
|
if hrefLabel != "" || href != "#" {
|
|
hasLink = true
|
|
}
|
|
}
|
|
|
|
data := CaseStudyCardData{
|
|
Client: getString(content, "client"),
|
|
Metric: getString(content, "metric"),
|
|
Label: getString(content, "label"),
|
|
Summary: getString(content, "summary"),
|
|
HrefLabel: hrefLabel,
|
|
Href: href,
|
|
HasLink: hasLink,
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
_ = caseStudyCardComponent(data).Render(ctx, &buf)
|
|
return buf.String()
|
|
}
|