builder

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package builder implements the HTML renderer, search index writer, and asset copier for kwelea.

The primary entry point is Build, which performs a two-pass pipeline:

  1. Parse pass — every non-draft Markdown page is processed by parser.Parse. The resulting HTML, table-of-contents, and optional H1 title are stored on each nav.Page.

  2. Render pass — each page is executed through the html/template pipeline (layout.html → page.html + partials) and written to <output_dir>/<path>/index.html.

After both passes, Build copies embedded CSS/JS/font assets to the output directory and writes search-index.json for client-side FlexSearch.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(site *nav.Site, embFS fs.FS, devMode bool) error

Build runs the full Phase 4 pipeline:

  1. Create output directory
  2. Copy embedded assets (CSS, JS, vendor)
  3. Generate and write chroma.css
  4. Load Go templates from embedded FS
  5. Parse all pages (fill Page.HTML and Page.TOC)
  6. Render all pages to HTML files

Types

type PageData

type PageData struct {
	Site         *nav.Site
	Page         *nav.Page
	SectionLabel string // nav section containing this page (empty for root pages)
	DevMode      bool   // true only during `kwelea serve`
	SourceURL    string // URL path to the co-located raw Markdown source file
}

PageData is the template context passed to every page render.

type SearchEntry

type SearchEntry struct {
	ID    string `json:"id"`
	Title string `json:"title"`
	Path  string `json:"path"`
	Body  string `json:"body"`
}

SearchEntry is one document in the search index written to search-index.json. The JS client loads this file and builds an in-memory FlexSearch index from it.

Jump to

Keyboard shortcuts

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