renderer

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssetSet

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

AssetSet accumulates CSS and JS assets for a single render pass.

Asset hooks append to the set, and the renderer publishes them into standard theme slots such as head.end and body.end.

func NewAssetSet

func NewAssetSet() *AssetSet

NewAssetSet creates an empty asset accumulator for a render pass.

func (*AssetSet) AddScript

func (a *AssetSet) AddScript(url string, pos ScriptPosition)

func (*AssetSet) AddStyle

func (a *AssetSet) AddStyle(url string)

func (*AssetSet) RenderInto

func (a *AssetSet) RenderInto(slots *Slots)

type BuildStats

type BuildStats struct {
	Prepare    time.Duration
	Assets     time.Duration
	Documents  time.Duration
	Taxonomies time.Duration
	Search     time.Duration
}

BuildStats records coarse timing breakdowns for a render/build pass.

type Hooks

type Hooks interface {
	OnContext(*ViewData) error
	OnAssets(*ViewData, *AssetSet) error
	OnBeforeRender(*ViewData) error
	OnAfterRender(url string, html []byte) ([]byte, error)
	OnAssetsBuilding(*config.Config) error
	OnHTMLSlots(*ViewData, *Slots) error
}

Hooks lets plugins participate in the render pipeline.

The hook order for a single page render is:

  1. OnContext
  2. OnAssets
  3. OnHTMLSlots
  4. OnBeforeRender
  5. >> template execution
  6. OnAfterRender

Implementations should keep work fast and deterministic because these hooks run for every rendered output.

type NavItem struct {
	Name   string
	URL    string
	Active bool
}

NavItem is a normalized menu item exposed to templates.

type Renderer

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

Renderer turns the site graph into HTML output using the active frontend theme and the provided render hooks.

func New

func New(cfg *config.Config, themes *theme.Manager, hooks Hooks) *Renderer

New constructs a renderer for the active theme.

func (*Renderer) Build

func (r *Renderer) Build(ctx context.Context, graph *content.SiteGraph) error

func (*Renderer) BuildTaxonomyArchives

func (r *Renderer) BuildTaxonomyArchives(ctx context.Context, graph *content.SiteGraph) error

func (*Renderer) BuildURLs

func (r *Renderer) BuildURLs(ctx context.Context, graph *content.SiteGraph, urls []string) error

func (*Renderer) BuildWithStats

func (r *Renderer) BuildWithStats(ctx context.Context, graph *content.SiteGraph) (BuildStats, error)

func (*Renderer) RenderNotFoundPage

func (r *Renderer) RenderNotFoundPage(graph *content.SiteGraph, requestPath string, liveReload bool) ([]byte, error)

func (*Renderer) RenderURL

func (r *Renderer) RenderURL(graph *content.SiteGraph, urlPath string, liveReload bool) ([]byte, error)

func (*Renderer) RenderURLWithQuery

func (r *Renderer) RenderURLWithQuery(graph *content.SiteGraph, urlPath string, rawQuery string, liveReload bool) ([]byte, error)

type ScriptPosition

type ScriptPosition string

ScriptPosition controls where a script asset is rendered in theme slots.

const (
	ScriptPositionHead    ScriptPosition = "head"
	ScriptPositionBodyEnd ScriptPosition = "body.end"
)

type Slots

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

Slots collects named HTML fragments that themes expose via pluginSlot in templates.

Asset hooks and HTML slot hooks populate Slots before template execution.

func NewSlots

func NewSlots() *Slots

NewSlots creates an empty slot registry for a single render pass.

func (*Slots) Add

func (s *Slots) Add(name string, html template.HTML)

Add appends an HTML fragment to a named slot.

Slot names should match the theme manifest's declared slots. Empty names and empty HTML fragments are ignored.

func (*Slots) Render

func (s *Slots) Render(name string) template.HTML

Render concatenates all fragments for a slot in insertion order.

type ViewData

type ViewData struct {
	Site         *config.Config
	Page         *content.Document
	Documents    []*content.Document
	Data         map[string]any
	Lang         string
	Title        string
	LiveReload   bool
	TaxonomyName string
	TaxonomyTerm string
	AuthorName   string
	SearchQuery  string
	RequestPath  string
	StatusCode   int
	Nav          []NavItem
}

ViewData is the template context passed to frontend theme layouts.

Theme authors can rely on these fields in templates, and render hooks may enrich or modify them before execution.

Jump to

Keyboard shortcuts

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