build

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 29 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package build turns a site's inputs into an immutable Site snapshot. Writing it to disk (build) or serving it from memory (dev) happens afterwards, so both share this code path.

Index

Constants

View Source
const NotFoundPath = "404.html"

NotFoundPath is the output path of the 404 page, served by both Cloudflare Pages and GitHub Pages from the output root.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache keeps parsed Markdown between builds, keyed by source path and the SHA-256 of the file. tryck dev uses one Cache for all rebuilds so unchanged pages skip goldmark parsing. A Cache is tied to one config: create a new one when the config changes.

Cached ASTs are only modified in stage 2 of a build, and only by link rewriting, which re-applies from the original destinations each time. One build at a time may use a Cache.

func NewCache

func NewCache() *Cache

NewCache returns an empty cache.

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of cached pages.

type Options

type Options struct {
	Dev     bool            // building for tryck dev
	Logger  *slog.Logger    // debug logs with per-stage timings; nil = silent
	Plugins []plugin.Plugin // compiled-in plugins in addition to the built-ins
	Cache   *Cache          // parsed pages reused between builds; nil = none
}

Options adjust a build.

type Site

type Site struct {
	Config  *config.Config
	Pages   []*content.Page // sorted by URL
	ByURL   map[string]*content.Page
	Nav     *nav.Node                      // read-only after stage 3
	Anchors map[string]map[string]struct{} // URL -> set of element IDs
	Assets  []content.Asset                // files from contentDir copied next to pages
	Outputs map[string][]byte              // output path -> bytes (pages + generated files)
	Diags   []diag.Diagnostic              // sorted
	BuiltAt time.Time
}

Site is the result of a build. It is not modified after Build returns.

func Build

func Build(ctx context.Context, cfg *config.Config, opts Options) (*Site, error)

Build runs the pipeline. It always returns a Site; check HasErrors. It returns ctx.Err() if the build was cancelled.

func (*Site) HasErrors

func (s *Site) HasErrors() bool

HasErrors reports whether the build produced error-level diagnostics.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL