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>
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
|
|
"git.dev.alexdunmow.com/block/core/blocks"
|
|
)
|
|
|
|
// WaveformPlayerBlockMeta declares the waveform audio player block.
|
|
var WaveformPlayerBlockMeta = blocks.BlockMeta{
|
|
Key: "waveform_player",
|
|
Title: "Waveform Player",
|
|
Description: "Soundcloud-style audio player with a canvas waveform.",
|
|
Source: "y2k",
|
|
Category: blocks.CategoryContent,
|
|
}
|
|
|
|
// WaveformPlayerBlock renders the audio block.
|
|
// Content: {trackTitle, audioUrl, artist, coverImage}
|
|
func WaveformPlayerBlock(ctx context.Context, content map[string]any) string {
|
|
data := WaveformPlayerData{
|
|
TrackTitle: getString(content, "trackTitle"),
|
|
AudioURL: getString(content, "audioUrl"),
|
|
Artist: getString(content, "artist"),
|
|
CoverImage: getString(content, "coverImage"),
|
|
}
|
|
if data.AudioURL == "" && data.TrackTitle == "" {
|
|
return ""
|
|
}
|
|
var buf bytes.Buffer
|
|
_ = waveformPlayerComponent(data).Render(ctx, &buf)
|
|
return buf.String()
|
|
}
|
|
|
|
// WaveformPlayerData is the typed shape for the templ component.
|
|
type WaveformPlayerData struct {
|
|
TrackTitle string
|
|
AudioURL string
|
|
Artist string
|
|
CoverImage string
|
|
}
|