Documentation
¶
Index ¶
- func BuildPhase1(cfg *config.Config) (map[string]string, error)
- func BuildPhase2(intermediateHTML map[string]string, ssrCfg *config.SSRConfig) (map[string]string, error)
- func DiscoverPlugins(cfg *config.Config) (*plugin.Registry, *plugin.HookRegistry, []string)
- func PrintStageTimings(w io.Writer, timings []StageTiming)
- type BuildOptions
- type BuildResult
- func Build(cfg *config.Config, opts ...BuildOptions) (*BuildResult, error)
- func BuildIncremental(cfg *config.Config, contentMap map[string]string, previousCache *cache.Cache, ...) (*BuildResult, error)
- func BuildWithContent(cfg *config.Config, contentMap map[string]string, opts ...BuildOptions) (*BuildResult, error)
- type Builder
- type DefaultBuilder
- type PipelineState
- type Profiler
- type ProgressReporter
- type RenderContext
- type StageTimer
- type StageTiming
- type TTYProgress
- func (p *TTYProgress) EndStage()
- func (p *TTYProgress) Message(text string)
- func (p *TTYProgress) StartStage(name string, total int)
- func (p *TTYProgress) Summary(pageCount int, duration time.Duration, pagesSkipped int)
- func (p *TTYProgress) Update(current int, filePath string, elapsed time.Duration)
- type VerboseProgress
- func (p *VerboseProgress) EndStage()
- func (p *VerboseProgress) Message(text string)
- func (p *VerboseProgress) StartStage(name string, total int)
- func (p *VerboseProgress) Summary(pageCount int, duration time.Duration, pagesSkipped int)
- func (p *VerboseProgress) Update(current int, filePath string, elapsed time.Duration)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildPhase1 ¶
BuildPhase1 runs Phase 1 (content rendering) and returns a map of source paths to intermediate HTML. Custom element tags are preserved as raw tags — they are not rendered until Phase 2 SSR.
func BuildPhase2 ¶
func BuildPhase2(intermediateHTML map[string]string, ssrCfg *config.SSRConfig) (map[string]string, error)
BuildPhase2 runs Phase 2 (SSR transform) on the intermediate HTML from Phase 1. For each page with custom elements, pipes the full page HTML to the ssr.command via stdin and reads transformed HTML from stdout. Pages without custom elements pass through unchanged. Mode "exec" (default): one process per page. Mode "stream": persistent process with NUL-delimited messages.
func DiscoverPlugins ¶
DiscoverPlugins creates a plugin registry and hook system, discovers plugins on disk, and loads them into the hook registry. Returns warnings for the caller to log (respects --quiet).
func PrintStageTimings ¶
func PrintStageTimings(w io.Writer, timings []StageTiming)
PrintStageTimings prints a formatted timing table for the given stage timings.
Types ¶
type BuildOptions ¶
type BuildOptions struct {
SkipSSR bool // true = skip Phase 2 entirely, regardless of cfg.SSR
CaptureRenderedContent bool // true = populate BuildResult.RenderedContent (test-only; default false halves peak memory)
PipelineState *PipelineState // pre-built state to reuse (BuildIncremental only)
Profile bool // true = record per-stage timing in BuildResult.StageTimings
Reporter ProgressReporter // progress output; nil = silent
}
BuildOptions controls optional pipeline behavior.
type BuildResult ¶
type BuildResult struct {
OutputDir string
PageCount int
PagesSkipped int // pages skipped via cache (incremental only)
SSRPagesRendered int // pages that went through Phase 2 SSR
Duration time.Duration
Errors []error
SSRSkipped bool // true when Phase 2 was skipped (no ssr: config or SkipSSR)
PagesRendered []string // source paths of pages that were rendered
RenderedContent map[string]string // page key → final rendered HTML (RelPath for regular pages, URL for generated pages)
FormatContent map[string]map[string]string // page key → format → rendered content (non-HTML format bodies, issue #1102)
ContentPassthroughs []string // relative paths of non-content files copied from content/ to output
StageTimings []StageTiming // per-stage durations (populated when BuildOptions.Profile is true)
Cache *cache.Cache // in-memory cache with content hashes for incremental rebuild (issue #639)
SiteData map[string]interface{} // enriched site data (data files + external sources + hooks)
}
BuildResult holds the outcome of a build.
func Build ¶
func Build(cfg *config.Config, opts ...BuildOptions) (*BuildResult, error)
Build runs the complete build pipeline (Phase 0 through Phase 3). Pass BuildOptions to control pipeline behavior (e.g., SkipSSR for dev mode).
func BuildIncremental ¶
func BuildIncremental(cfg *config.Config, contentMap map[string]string, previousCache *cache.Cache, changedFiles []string, opts ...BuildOptions) (*BuildResult, error)
BuildIncremental renders only pages that have changed since the previous build (per the cache) or were invalidated by a layout/data change. Used by alloy dev for incremental rebuilds on file watcher events. When contentMap is nil, content is discovered from the filesystem. If previousCache is nil, all pages are rendered (equivalent to full build).
func BuildWithContent ¶
func BuildWithContent(cfg *config.Config, contentMap map[string]string, opts ...BuildOptions) (*BuildResult, error)
BuildWithContent runs the pipeline with injected content for testing. The content map keys are source paths, values are raw file content.
type Builder ¶
type Builder interface {
Build(cfg *config.Config, opts ...BuildOptions) (*BuildResult, error)
BuildIncremental(cfg *config.Config, contentMap map[string]string, previousCache *cache.Cache, changedFiles []string, opts ...BuildOptions) (*BuildResult, error)
}
Builder abstracts the build pipeline so callers (e.g. cmd/dev.go) can be tested with a mock instead of running the full pipeline.
type DefaultBuilder ¶
type DefaultBuilder struct{}
DefaultBuilder delegates to the package-level Build and BuildIncremental functions.
func (*DefaultBuilder) Build ¶
func (b *DefaultBuilder) Build(cfg *config.Config, opts ...BuildOptions) (*BuildResult, error)
func (*DefaultBuilder) BuildIncremental ¶
func (b *DefaultBuilder) BuildIncremental(cfg *config.Config, contentMap map[string]string, previousCache *cache.Cache, changedFiles []string, opts ...BuildOptions) (*BuildResult, error)
type PipelineState ¶
type PipelineState struct {
Engine tmpl.TemplateEngine
Registry *plugin.Registry
Hooks *plugin.HookRegistry
CascadeData map[string]map[string]interface{}
SiteData map[string]interface{}
ContentDir string
ContentBase string
}
PipelineState holds shared state initialized once per build. Used by both Build() and BuildIncremental() to avoid duplicating setup.
func InitPipelineState ¶
func InitPipelineState(cfg *config.Config, registry *plugin.Registry, hooks *plugin.HookRegistry) (*PipelineState, error)
InitPipelineState creates the template engine with plugin extensions, loads cascade and site data. Shared by Build() and BuildIncremental().
type Profiler ¶
type Profiler struct {
// contains filtered or unexported fields
}
Profiler manages pprof CPU and memory profiling for a build.
func StartProfiling ¶
StartProfiling begins CPU profiling in the given directory. The directory is created if it does not exist.
func (*Profiler) StopProfiling ¶
StopProfiling stops CPU profiling and writes a heap profile to mem.prof. GC runs before the heap snapshot so freed objects don't inflate the profile.
type ProgressReporter ¶
type ProgressReporter interface {
StartStage(name string, total int)
Message(text string)
Update(current int, filePath string, elapsed time.Duration)
EndStage()
Summary(pageCount int, duration time.Duration, pagesSkipped int)
}
ProgressReporter receives pipeline stage updates for build progress output. Passed via BuildOptions.Reporter. Nil means no progress output.
type RenderContext ¶
type RenderContext struct {
Cfg *config.Config
SiteData map[string]interface{}
CollectionsCtx map[string]interface{}
TaxonomiesCtx map[string]interface{}
LangContexts []i18n.LanguageContext
Pages []*content.Page
Engine tmpl.TemplateEngine
TemplateUsage map[string][]string
LayoutCache map[string]tmpl.Template
Goldmark goldmark.Markdown
PermalinkCfg map[string]string
Registry *plugin.Registry
}
RenderContext bundles shared rendering state passed through the render call chain, reducing parameter counts on renderPages and related functions.
type StageTimer ¶
type StageTimer struct {
// contains filtered or unexported fields
}
StageTimer records durations of named pipeline stages.
func (*StageTimer) Report ¶
func (t *StageTimer) Report(w io.Writer)
Report prints a formatted timing table of this timer's recorded stages. Safe to call on a nil receiver (no-op).
func (*StageTimer) Start ¶
func (t *StageTimer) Start(name string)
Start begins timing a named stage. If a previous stage is still running, it is stopped first. Safe to call on a nil receiver (no-op).
func (*StageTimer) Stop ¶
func (t *StageTimer) Stop()
Stop ends the current stage and records its duration. Safe to call on a nil receiver (no-op).
func (*StageTimer) Timings ¶
func (t *StageTimer) Timings() []StageTiming
Timings returns the recorded stage timings. Safe to call on a nil receiver (returns nil).
type StageTiming ¶
StageTiming records the name and duration of a single pipeline stage.
type TTYProgress ¶
type TTYProgress struct {
// contains filtered or unexported fields
}
TTYProgress displays a progress bar with carriage return for interactive terminals.
func NewTTYProgress ¶
func NewTTYProgress(w io.Writer, width int) *TTYProgress
NewTTYProgress creates a progress reporter for interactive terminals. width is the terminal width for progress bar sizing.
func (*TTYProgress) EndStage ¶
func (p *TTYProgress) EndStage()
func (*TTYProgress) Message ¶
func (p *TTYProgress) Message(text string)
func (*TTYProgress) StartStage ¶
func (p *TTYProgress) StartStage(name string, total int)
type VerboseProgress ¶
type VerboseProgress struct {
// contains filtered or unexported fields
}
VerboseProgress displays per-file output with timing.
func NewVerboseProgress ¶
func NewVerboseProgress(w io.Writer) *VerboseProgress
NewVerboseProgress creates a progress reporter for --verbose mode.
func (*VerboseProgress) EndStage ¶
func (p *VerboseProgress) EndStage()
func (*VerboseProgress) Message ¶
func (p *VerboseProgress) Message(text string)
func (*VerboseProgress) StartStage ¶
func (p *VerboseProgress) StartStage(name string, total int)