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 }