guide

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package guide is akari's self-hosted user guide: the Markdown chapters, the ordered chapter registry, and the rendering that turns them into the HTML the web layer shows and the plain-text forms an agent ingests.

The chapters live as plain Markdown under content/ (embedded in the binary), each starting with its H1. Chapter metadata (title, summary, order, slug) is a typed registry here rather than frontmatter parsed out of the files, so the ordering and nav are compile-time data and the served .md stays clean, self-contained Markdown.

Rendering is goldmark with GFM (tables and the like) and GitHub-style heading ids. A small AST pass rewrites the relative cross-links the chapters use (./glossary.md) to the hosted routes (/guide/glossary) for the HTML view, while the raw .md the agents fetch keeps the portable relative form. The same parse pass collects the H2/H3 headings the table of contents rail is built from.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LLMsFullTxt

func LLMsFullTxt(base string) (string, error)

LLMsFullTxt renders llms-full.txt: every chapter concatenated in reading order, each section prefixed with an HTML comment carrying its canonical URL so a fact can be cited back to a page. An agent ingests the whole guide in one request instead of crawling.

func LLMsTxt

func LLMsTxt(base string) string

LLMsTxt renders the llms.txt discovery index (https://llmstxt.org): a short header and a link to every chapter's raw Markdown, so an agent learns the guide's shape in one fetch and can pull any page as Markdown. base is the server's external origin, no trailing slash.

Types

type Chapter

type Chapter struct {
	// Slug is the URL slug. The overview page uses "index" and renders at
	// /guide; every other chapter renders at /guide/<slug>.
	Slug string
	// Title matches the chapter's H1 and labels it in the nav and the index.
	Title string
	// Summary is the one-line description used for the page's meta description and
	// the llms.txt index. It does not render on the page itself.
	Summary string
	// Order sets reading order: 0 is the overview, 1..n the chapters. It is the
	// sole ordering key, so a chapter can be renamed without disturbing the
	// sequence.
	Order int
	// contains filtered or unexported fields
}

Chapter is one page of the guide. The prose lives in the embedded Markdown file; the metadata here drives the sidebar, the table of contents, and the machine-readable index.

func Chapters

func Chapters() []Chapter

Chapters returns the guide's chapters in reading order.

func Lookup

func Lookup(slug string) (Chapter, bool)

Lookup returns the chapter for a slug, false if there is none. The empty slug and "index" both resolve to the overview, so /guide and /guide/index.md agree.

func (Chapter) GitHubURL

func (c Chapter) GitHubURL() string

GitHubURL is the source location of a chapter's Markdown, for the "Edit on GitHub" page action.

func (Chapter) IsIndex

func (c Chapter) IsIndex() bool

IsIndex reports whether this is the overview/index chapter (order 0), which renders at /guide rather than /guide/<slug>.

func (Chapter) Neighbors

func (c Chapter) Neighbors() (prev, next *Chapter)

Neighbors returns the previous and next chapters in reading order, either nil at an end of the chain. It powers the prev/next footer.

func (Chapter) Raw

func (c Chapter) Raw() (string, error)

Raw returns the chapter's Markdown source, trimmed with a single trailing newline. This is the exact text served at the .md route, copied by "Copy page", and concatenated into llms-full.txt.

func (Chapter) RawRoute

func (c Chapter) RawRoute() string

RawRoute is the route serving the chapter's raw Markdown.

func (Chapter) Render

func (c Chapter) Render() (Rendered, error)

Render renders the chapter to HTML and collects its H2/H3 headings in one parse. A render failure is returned rather than swallowed: a broken chapter should surface as a server error, not a blank page.

func (Chapter) Route

func (c Chapter) Route() string

Route is the HTML route the chapter renders at.

type Heading

type Heading struct {
	Level int
	ID    string
	Text  string
}

Heading is one entry in a chapter's table of contents: an H2 or H3 with the id its anchor targets.

type Rendered

type Rendered struct {
	HTML     template.HTML
	Headings []Heading
}

Rendered is a chapter's HTML body plus the headings its table of contents is built from.

Jump to

Keyboard shortcuts

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