Documentation
¶
Index ¶
- func BuildOutputPath(dir string) (string, error)
- func CleanOutput(outputDir string) error
- func CopyAssets(assets []discover.FileEntry, contentDir, outputDir string) error
- func CopyPackStatic(packs []core.Pack, outputDir string) error
- func CopyPublicDir(staticDir, outputDir string) error
- func DefaultRenderer(nodes []core.Node) template.HTML
- func JSONPayload(envelope core.Envelope, nodes []core.Node, url string) (string, error)
- func RenderAll(ctx context.Context, pages []*core.Page, cfg *config.Config, packs []core.Pack, ...) []core.EngineError
- func RenderOutputs(pages []*core.Page, cfg *config.Config, packs []core.Pack) []core.EngineError
- type OutputData
- type PageRef
- type PageTemplateData
- type SiteTemplateData
- type TemplateCache
- type TemplateData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildOutputPath ¶
BuildOutputPath returns the output directory, resolving relative paths against the current working directory.
func CleanOutput ¶
CleanOutput removes and recreates the output directory for a fresh build.
func CopyAssets ¶
CopyAssets copies content-colocated binary assets (images, fonts, PDFs, etc.) to mirrored paths in the output directory, preserving directory structure.
func CopyPackStatic ¶
CopyPackStatic copies each pack theme's static/ subtree to the output root, so a pack can ship its own CSS, JS, and images. Packs are applied in registration order (later packs overwrite earlier ones); the user's public/ directory is copied afterward by CopyPublicDir, so user files always win.
func CopyPublicDir ¶
CopyPublicDir copies the contents of the public/static directory verbatim to the output root. Files like favicon.ico, robots.txt, and _redirects are served at their original paths relative to the site root.
func DefaultRenderer ¶
DefaultRenderer produces semantic HTML from a []Node tree using <div data-type="..."> wrappers. This is the fallback when no per-type renderer template is available.
func JSONPayload ¶
JSONPayload serializes the page envelope and nodes into a JSON string safe for embedding in HTML via <script type="application/json">. Uses json.Marshal which escapes <, >, & to unicode sequences.
func RenderAll ¶
func RenderAll(ctx context.Context, pages []*core.Page, cfg *config.Config, packs []core.Pack, changed map[string]bool, narrow bool) []core.EngineError
RenderAll renders pages to HTML files in the output directory, in parallel.
On a narrowed incremental rebuild (narrow=true), only the affected set is re-rendered: pages whose content changed (changed[RelPath]), all virtual pages (they aggregate content), and pages whose template reads .Site.Pages. Site-blind, unchanged pages keep their existing output. With narrow=false, every page is rendered. The .Site.Pages refs are always built from the full page set.
func RenderOutputs ¶
RenderOutputs executes every file under theme/outputs/ (user theme and pack themes, user wins) as a text/template fed with .Site, writing the result to the same relative path in the output directory. text/template is deliberate: outputs are XML/JSON/plain text, where html/template escaping would corrupt the result.
Types ¶
type OutputData ¶
type OutputData struct {
Site SiteTemplateData
}
OutputData is the data passed to site-level output templates.
type PageRef ¶
PageRef is the slim cross-page reference exposed as .Site.Pages. It deliberately omits Nodes and rendered content: refs exist for navs, listings, and envelope-driven queries, not for rendering other pages' bodies (which would make builds O(n²)).
func BuildPageRefs ¶
BuildPageRefs projects pages into URL-sorted refs. Pages marked Skip are excluded. The result is built once per build and shared read-only across render workers.
type PageTemplateData ¶
type PageTemplateData struct {
Envelope core.Envelope
Content template.HTML
URL string
Layout string
Type string
}
PageTemplateData contains the current page's data for templates.
type SiteTemplateData ¶
SiteTemplateData contains global site data for templates.
type TemplateCache ¶
type TemplateCache struct {
// contains filtered or unexported fields
}
TemplateCache holds all pre-parsed templates for rendering.
func LoadTemplates ¶
func LoadTemplates(themeDir string, packs []core.Pack) (*TemplateCache, error)
LoadTemplates pre-parses all templates from the user theme directory layered over any registered pack themes. The user's files always win; among packs, later registration wins with a logged warning.
func (*TemplateCache) GetLayout ¶
func (tc *TemplateCache) GetLayout(name string) *template.Template
GetLayout returns the template for the given layout name. Falls back to the base template if no matching layout is found.
func (*TemplateCache) UsesJSON ¶
func (tc *TemplateCache) UsesJSON(tmpl *template.Template) bool
UsesJSON reports whether the given (already resolved) template references .JSON anywhere in its tree.
func (*TemplateCache) UsesSitePages ¶
func (tc *TemplateCache) UsesSitePages(tmpl *template.Template) bool
UsesSitePages reports whether the given resolved template reads .Site.Pages, meaning its output can change when any other page is added, removed, or edited.
type TemplateData ¶
type TemplateData struct {
Page PageTemplateData
Site SiteTemplateData
Paginator *core.Paginator // set on paginated listing pages, nil otherwise
JSON template.JS // raw JSON blob, safe for embedding in <script>
}
TemplateData is the data passed to each page template.