Documentation
¶
Overview ¶
Package site compiles the playlist hub into a static, navigable web site: one page per playlist embedding <byom-player>, a tree mirroring the hub's subdirectories, a shared nav index, Open Graph metadata, and an RSS feed.
Index ¶
- func Build(opts Options) error
- func CopyArt(hubDir, outDir string) error
- func GenerateMosaics(hubDir, outDir string, root *Node) error
- func WriteAssets(outDir string) error
- func WriteCNAME(outDir, baseURL string) error
- func WriteFeed(outDir string, site SiteMeta, root *Node) error
- func WriteIndexJSON(outDir string, root *Node) error
- func WriteJSPF(outDir string, root *Node, baseURL string) error
- type ContentPage
- type Crumb
- type IndexNode
- type Node
- type Options
- type PageLink
- type Renderer
- type SiteIndex
- type SiteMeta
- type YearGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyArt ¶
CopyArt copies the hub's downloaded cover-art store (<hubDir>/art) into <outDir>/art so the static site can serve it. A missing art dir is a no-op.
func GenerateMosaics ¶
GenerateMosaics builds a representative cover mosaic for each playlist that has no explicit hero image, writes it to <outDir>/art/mosaic/<slug>.jpg, and sets the in-memory Playlist.ImageFile so the existing hero precedence carries it into the JSPF and og:image. The mosaic filename is the playlist's slug path (predictable + stable across rebuilds). Generation is skipped when the mosaic already exists and is at least as new as the playlist's source YAML, so unchanged playlists don't pay the cover-read + render cost. Playlists with an explicit hero, or with no downloaded covers, are left untouched.
func WriteAssets ¶
WriteAssets copies the embedded assets/ directory into outDir/assets/.
func WriteCNAME ¶
WriteCNAME writes a GitHub Pages CNAME file with the host from baseURL. It is a no-op when baseURL is empty or has no host.
func WriteFeed ¶
WriteFeed writes an RSS feed of playlists, newest first by DateCreated and capped at site.FeedItemLimit.
Nodes are collected and sorted before any item body is built: each body embeds a full tracklist and is stored twice (description and content:encoded), so rendering playlists that the cap discards would be the bulk of the work.
func WriteIndexJSON ¶
WriteIndexJSON writes the featured list and the nav tree (root's children) to site-index.json.
Types ¶
type ContentPage ¶
ContentPage is a render-ready standalone markdown page.
func LoadPages ¶
func LoadPages(dir string) ([]ContentPage, error)
LoadPages reads every *.md in dir into a sorted slice of ContentPages. A missing directory yields (nil, nil) — content pages are opt-in.
type IndexNode ¶
type IndexNode struct {
Name string `json:"name"`
Title string `json:"title"`
Path string `json:"path"`
IsDir bool `json:"isDir"`
Meta string `json:"meta,omitempty"` // playlist summary line (leaves only)
Image string `json:"image,omitempty"` // resolved cover href (leaves only)
Year int `json:"year,omitempty"`
Children []IndexNode `json:"children,omitempty"`
}
IndexNode is the nav projection of a Node serialized into site-index.json (no track data beyond the summary Meta line). It appears both in the nav tree and in the flat featured list. Path is absolute-from-root with leading + trailing slashes.
type Node ¶
type Node struct {
Name string
Title string
Path string
IsDir bool
IntroMD string // raw markdown from the folder's README.md (root and subdirs)
Playlist *playlist.Playlist
Children []*Node
}
Node is one entry in the site tree: either a directory (IsDir) with Children, or a playlist leaf carrying its loaded Playlist. Path is the slash-joined slug path from the hub root ("" for the root itself).
type Options ¶
type Options struct {
HubDir string
OutDir string
PagesDir string
Site SiteMeta
// Logger narrates build phases; nil → a default logrus logger.
Logger logrus.FieldLogger
}
Options configures a site build.
type Renderer ¶
type Renderer struct {
Site SiteMeta
// contains filtered or unexported fields
}
Renderer holds the parsed template set and site settings.
func NewRenderer ¶
NewRenderer parses the embedded templates.
func (*Renderer) RenderPages ¶
func (r *Renderer) RenderPages(outDir string, pages []ContentPage) error
RenderPages writes one HTML page per content page at <outDir>/pages/<slug>/index.html.
type SiteIndex ¶
type SiteIndex struct {
Featured []IndexNode `json:"featured,omitempty"`
Children []IndexNode `json:"children"`
}
SiteIndex is the payload of site-index.json: the flat Featured list plus the nav tree. Featured is sorted here rather than client-side because Go has the full playlist dates and IndexNode only carries the year.
type SiteMeta ¶
type SiteMeta struct {
Title string
BaseURL string
PlayerSrc string
Provider string
Providers []string
YouTubeSearchEndpoint string
SpotifyClientID string
Pages []PageLink
// FeedTrackLimit caps how many tracks each RSS item lists. A value > 0
// truncates and adds an "…and N more" link; <= 0 lists every track.
FeedTrackLimit int
// FeedItemLimit caps how many playlists the RSS feed carries, newest first.
// A value > 0 truncates; <= 0 includes every playlist.
FeedItemLimit int
}
SiteMeta carries site-wide settings baked into every page.