docs

package
v1.33.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const AssetPrefix = "/docs/"

AssetPrefix is where the dashboard serves the images the docs reference.

View Source
const RoutePrefix = "#docs/"

RoutePrefix is the dashboard hash route a documentation page lives at.

Variables

This section is empty.

Functions

func AssetURL

func AssetURL(dest, section string) string

AssetURL rewrites a file reference in the docs into the URL the binary serves it from. Site-absolute paths keep their shape under the prefix, relative ones resolve against the page's section.

func Normalize

func Normalize(md string) string

Normalize rewrites the VitePress-flavoured markdown under docs/ into portable markdown. Containers become blockquotes, code-group fence labels become a bold line above their block, and the inline HTML VitePress needs to escape template braces becomes a code span, so a plain CommonMark renderer shows the page instead of leaking the syntax. Both `lerd man` and the dashboard read it.

func PageHref

func PageHref(dest string, from Page) string

PageHref rewrites a link between documentation pages into the dashboard route that shows it. Anchors survive, and an image or download link keeps pointing at the served file.

func RenderHTML

func RenderHTML(p Page) (string, error)

RenderHTML renders a page to an HTML fragment for the dashboard. Links between pages become dashboard routes and images become URLs the binary serves, so a reader never leaves the machine. Raw HTML is dropped rather than emitted.

func SectionLabel

func SectionLabel(section string) string

SectionLabel returns the display name for a section key.

Types

type Page

type Page struct {
	Title   string
	Section string
	Slug    string
	Path    string
	// contains filtered or unexported fields
}

Page represents a single documentation page.

func BuildRegistry

func BuildRegistry() []Page

BuildRegistry walks the embedded docs FS and returns all pages in section order.

func FilterPages

func FilterPages(pages []Page, filter string) []Page

FilterPages returns pages whose title or content contains the filter string (case-insensitive).

func (Page) Content

func (p Page) Content() string

Content returns the raw markdown content of the page.

func (Page) Route

func (p Page) Route() string

Route returns the page's address inside a surface: "usage/sites" for a sectioned page, "changelog" for a top-level one.

type Result

type Result struct {
	Title   string `json:"title"`
	Section string `json:"section"`
	Slug    string `json:"slug"`
	Route   string `json:"route"`
	Snippet string `json:"snippet"`
}

Result is one page matching a search, with a snippet of the surrounding prose.

func Search(pages []Page, query string, limit int) []Result

Search returns the pages matching the query, title matches first, each with a snippet of the text around the first hit. A blank query returns nothing.

Jump to

Keyboard shortcuts

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