Documentation
¶
Overview ¶
Package book assembles Markdown manuscripts into book-shaped websites using the Runvil web framework. A manuscript is a directory of ordered Markdown files and subdirectories; the builder renders it into pages and assets that can be exported to disk or served over HTTP.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Assets ¶
Assets returns the site's shipped assets: name to file body. The theme-mode variables and toggle button styles come from the ui framework and are appended to the reader stylesheet so consumers never hardcode them.
Types ¶
type Book ¶
type Book struct {
// Title is the book title.
Title string
// Author is the book author.
Author string
// Chapters holds the top-level chapters in reading order.
Chapters []Chapter
// contains filtered or unexported fields
}
Book is a manuscript, loaded into an ordered set of chapters.
func Load ¶
Load reads a manuscript directory into a Book in reading order, served from the site root.
func LoadWithBase ¶ added in v0.2.0
LoadWithBase reads a manuscript directory into a Book in reading order. Top level Markdown files become chapters; a directory becomes a chapter whose subchapters are the Markdown files inside it, ordered by numeric prefix. An index.md or _index.md inside a directory becomes the chapter page body; without one, the chapter page lists its subchapters automatically. The base is the URL prefix the site will be served under, e.g. "/guide/".
func (*Book) Handler ¶
Handler returns an http.Handler that serves the book's pages and assets through the web router.
func (*Book) Pages ¶
Pages builds the site's web.Page tree: the root landing page and one page per chapter. Exported page paths are always root-relative; only the links emitted into the rendered HTML carry the book's base path.
func (*Book) WithChrome ¶ added in v0.3.0
WithChrome sets the book's navigation chrome: optional navbar links and footer text. Returns the Book for chaining.
type Chapter ¶
type Chapter struct {
// Number is the 1-based reading order index of the top-level chapter.
Number int
// Sub is the 1-based subchapter index within the parent chapter, or 0 for
// a top-level chapter.
Sub int
// Slug is the URL-safe identifier derived from the filename.
Slug string
// Title is the chapter title derived from the first H1 heading or slug.
Title string
// Body is the rendered HTML body.
Body template.HTML
// Prev and Next point to adjacent pages in reading order.
Prev *Chapter
Next *Chapter
// Subs holds the chapter's subchapters in reading order; empty for a
// plain chapter.
Subs []*Chapter
// Parent points to the containing chapter, or nil for top-level chapters.
Parent *Chapter
}
Chapter is one manuscript unit, named by its slug and rendered from Markdown. A chapter with subchapters mirrors a part of a physical book: the chapter page leads, and its Subs follow as "N.M" subchapters.
type Config ¶
type Config struct {
// Title is the book title.
Title string
// Author is the book author.
Author string
// Input is the manuscript directory.
Input string
// Output is the destination directory for the exported site.
Output string
// BasePath is the URL base the site will be served under, e.g. "/guide/".
// Generated links and asset references are prefixed accordingly. Defaults
// to "/".
BasePath string
NavLinks []Link
// shows the author copyright instead.
FooterText string
// Theme, when non-nil, enables the light/dark theme switcher on every page.
Theme *ui.Theme
}
Config configures a build.