Documentation
¶
Overview ¶
Package repotheme is the Fuego repo theme: point it at any repository and it renders every text file — Markdown as HTML, everything else as a line-numbered source page — as one navigable site that mirrors the repo's own folder structure. It is the generic, zero-config sibling of fuego-systheme: no fuego-formats dependency, no per-format opinions, just the engine's markdown parser plus one catch-all source parser.
Register it on any Fuego engine with eng.Use(repotheme.Pack()), or point the fuego-repo CLI at a repository; nothing is written into the repo either way.
Index ¶
- Constants
- func BuildNavTree(pages []*core.Page) ([]*core.Page, error)
- func EnrichLayouts(pages []*core.Page) ([]*core.Page, error)
- func HomeFromReadme(pages []*core.Page) ([]*core.Page, error)
- func Pack() core.Pack
- func RewriteContentLinks(pages []*core.Page) ([]*core.Page, error)
- func Run(repoPath string, opts Options) error
- type Options
Constants ¶
const SourceType = "source"
SourceType is the page type for every non-Markdown text file. Markdown keeps the engine markdown parser's own type ("md"); everything the source parser claims is this.
Variables ¶
This section is empty.
Functions ¶
func BuildNavTree ¶
BuildNavTree (a BeforeRender hook, registered last) assembles the repository file tree the sidebar renders on every page: directories nested as in the repo, one leaf per rendered page. Each leaf carries a "cat" of "doc" (Markdown) or "code" (everything else) so the sidebar's show-code toggle can hide code by default. The tree is built once and shared by reference on every envelope — JSON-shaped and read-only from the templates' side.
func EnrichLayouts ¶
EnrichLayouts (an AfterParse hook) assigns the layout and a display title to every page, since neither parser sets one: Markdown pages render as prose (layout "doc"), source files as a code page (layout "source"). Titles fall back to the file's base name because a parser cannot see the filename. All envelope values written here are JSON-shaped, so pages stay cache-eligible.
func HomeFromReadme ¶
HomeFromReadme (an Index hook, after ROUTE) makes the site's index page the repository's README — but never requires one. If a root README.md rendered as a page, its URL is moved to "/" and it renders through the home layout. If there is no README (or something already owns "/", e.g. a root index.md), a minimal virtual home is synthesized listing the top-level entries, so a README-less repo still produces a working landing page instead of breaking.
func Pack ¶
Pack returns the repo theme format pack: the engine's markdown parser (for .md → HTML) plus the catch-all source parser (every other text file → line-numbered page), the theme, ignore defaults, and the hooks that default layouts, build the optional README home, rewrite in-repo links, and assemble the file-tree sidebar.
The two parsers layer cleanly: source claims a curated set of text extensions and extensionless names, none of which is *.md, so Markdown falls through to the markdown parser's own extension claim. Anything neither claims (images, PDFs, unknown/binary files) stays an asset the engine copies verbatim — so README images render and files stay downloadable.
func RewriteContentLinks ¶
RewriteContentLinks (a BeforeRender hook) keeps a repository's own relative Markdown links working on the rendered site. A repo's Markdown is written for the GitHub view — "see [main.go](./main.go)" or "[the schema](db/schema.sql)" — so this hook resolves each relative href against the page's source location and, when the target file rendered as a page (Markdown or source), rewrites the href to that page's relative URL. Absolute URLs, anchors, mailto, and links to files that aren't pages (e.g. images the engine copied as assets) pass through untouched. This is what makes browsing the repo — and -strict-links — viable over an unmodified checkout.
Types ¶
type Options ¶
type Options struct {
SiteName string // site title (default: "Repository")
BaseURL string // base URL for the site (default: "")
Output string // output directory (default: "build")
Command string // "build", "serve", or "validate" (default: "serve")
StrictLinks bool // fail the build on a broken internal link
}
Options configures a fuego-repo site build.