Alex Dunmow 4713787bbd initial: theme plugin corporate-modernist
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>
2026-06-06 14:11:24 +08:00

56 lines
1.3 KiB
Go

package main
import (
"bytes"
"context"
"git.dev.alexdunmow.com/block/core/blocks"
)
// LogoStripMeta is the block metadata for corporate-modernist:logo_strip.
var LogoStripMeta = blocks.BlockMeta{
Key: "logo_strip",
Title: "Client Logo Strip",
Description: "Row of client logos, greyscale until hover.",
Source: "corporate-modernist",
Category: blocks.CategoryContent,
}
// LogoStripItem represents a single logo entry in the strip.
type LogoStripItem struct {
Src string
Alt string
Href string
}
// LogoStripData carries the parsed content for the logo_strip block.
type LogoStripData struct {
Caption string
Logos []LogoStripItem
}
// LogoStripBlock renders the logo_strip block.
func LogoStripBlock(ctx context.Context, content map[string]any) string {
rawLogos := getSlice(content, "logos")
logos := make([]LogoStripItem, 0, len(rawLogos))
for _, l := range rawLogos {
alt := getString(l, "alt")
src := getString(l, "src")
href := getString(l, "href")
// Skip entries with no asset reference and no alt text.
if src == "" && alt == "" {
continue
}
logos = append(logos, LogoStripItem{Src: src, Alt: alt, Href: href})
}
data := LogoStripData{
Caption: getString(content, "caption"),
Logos: logos,
}
var buf bytes.Buffer
_ = logoStripComponent(data).Render(ctx, &buf)
return buf.String()
}