Documentation
¶
Overview ¶
Package render loads layout templates and executes them for pages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMissingLayout = errors.New("layout not found")
ErrMissingLayout is returned by Execute for an unknown layout name.
Functions ¶
func AbsURL ¶
AbsURL is RelURL with baseURL's scheme and host. If baseURL has no host it behaves like RelURL.
func Funcs ¶
func Funcs(o FuncOptions) template.FuncMap
Funcs returns the template functions (spec §9.3). "partial" is bound to each layout's template set by Load.
Types ¶
type Dir ¶
Dir is a layouts directory and how it is named in diagnostics (relative to the project root).
type FuncOptions ¶
type FuncOptions struct {
BaseURL string
DateFormat string // default layout for dateFormat
Markdownify func(string) (string, error) // inline Markdown to HTML
}
FuncOptions configures the template functions of a site.
type TemplateData ¶
type TemplateData struct {
Site SiteInfo
Page *PageInfo
Content template.HTML // rendered body, already trusted
TOC []plugin.TOCEntry // from the toc plugin, nil if disabled
Prev, Next *PageInfo // nil at the ends
Stylesheets []string // site paths of plugin CSS to link in <head>
Theme ThemeData // theme settings from the config
Dev bool // true in tryck dev
}
TemplateData is the dot value of every layout (spec §9.2).
type Templates ¶
type Templates struct {
// contains filtered or unexported fields
}
Templates holds one executable template set per layout.
func Load ¶
Load parses the embedded default layouts, overridden file by file by those in dirs (lowest priority first: the theme's, then the site's). Directories that do not exist are skipped.
type ThemeData ¶
type ThemeData struct {
Accent template.CSS // validated CSS color, or ""
AccentDark template.CSS // accent in dark mode
Logo string // site path
ColorScheme string // auto, light or dark
CSS []string // extra stylesheets
Params map[string]any
}
ThemeData is the theme section of the config, ready for templates.