Documentation
¶
Overview ¶
Package pages loads user-authored markdown files from a directory and renders them as additional Compass pages.
Files are read on demand at request time so updating a file is reflected on the next page load without restarting the server.
Layout ¶
The configured directory may contain top-level *.md files and/or sub-directories of *.md files. Each top-level file becomes /pages/{slug}. Each sub-directory becomes its own nav dropdown with URLs of the form /pages/{section}/{slug}. Sub-directory names may be prefixed with a numeric order (01-administration) which is stripped from the displayed title.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader knows how to list and render pages from a directory.
func (*Loader) Backlinks ¶
Backlinks returns every page whose body mentions serviceID, either via a `[[id]]` / `[[name]]` wiki-link or one of the service-targeting shortcodes (`{{< service id=X >}}`, `{{< panel service=X >}}`). Walks the pages directory once per call — at homelab scale (dozens of files) the cost is negligible and keeps the "edit a page, see it next request" promise intact.
Pass the same services slice you'd pass to Get; the lookup matches by ID or by display name (case-insensitive).
func (*Loader) Get ¶
func (l *Loader) Get( section, slug string, services []compass.Service, ) (Page, template.HTML, []TOCEntry, error)
Get loads, parses, and renders a single page. Pass section="" for a top-level page. Services are passed in for shortcode expansion (see {{< services tag=foo >}}); pass nil if shortcode results aren't needed. Returns the rendered HTML and the page's heading TOC.
type Page ¶
type Page struct {
Slug string // file slug (without .md)
Section string // section slug; "" for top-level pages
Title string
Order int
Tags []string
UpdatedAt time.Time // file mtime; zero when stat fails
}
Page describes one markdown page.