themes-earthen/partner_logos.go
Alex Dunmow 49401f1b41 initial: theme plugin earthen
Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously
an unversioned directory inside ~/src/blockninja-themes/earthen.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 14:11:27 +08:00

56 lines
1.3 KiB
Go

package main
import (
"bytes"
"context"
"git.dev.alexdunmow.com/block/core/blocks"
)
// PartnerLogosBlockMeta defines metadata for the partner logos block.
var PartnerLogosBlockMeta = blocks.BlockMeta{
Key: "partner_logos",
Title: "Partner Logos",
Description: "Grayscale partner logo grid with hover-to-color treatment",
Source: "earthen",
Category: blocks.CategoryContent,
}
// PartnerLogosBlock renders the partner logos block.
// Content shape: {title, logos:[{name,image,url}]}
func PartnerLogosBlock(ctx context.Context, content map[string]any) string {
rawLogos := getSlice(content, "logos")
logos := make([]PartnerLogo, 0, len(rawLogos))
for _, l := range rawLogos {
logos = append(logos, PartnerLogo{
Name: getString(l, "name"),
Image: getString(l, "image"),
URL: getString(l, "url"),
})
}
data := PartnerLogosData{
Title: getString(content, "title"),
Logos: logos,
Empty: len(content) == 0,
}
var buf bytes.Buffer
_ = partnerLogosComponent(data).Render(ctx, &buf)
return buf.String()
}
// PartnerLogosData contains data for the partner logos component.
type PartnerLogosData struct {
Title string
Logos []PartnerLogo
Empty bool
}
// PartnerLogo is a single partner row.
type PartnerLogo struct {
Name string
Image string
URL string
}