gen

package
v0.0.0-...-0240d16 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSiteStructure

func BuildSiteStructure(site *SiteInfo)

--- buildSiteStructure (MODIFIED) --- This function now walks up the directory tree to find the nearest parent section.

func CleanOutputDir

func CleanOutputDir(dir string) error

--- cleanOutputDir - Unchanged ---

func CopyStaticFiles

func CopyStaticFiles(staticDir, outputDir string) error

--- copyStaticFiles - Unchanged ---

func LoadTemplates

func LoadTemplates(layoutDir string) (*template.Template, error)

--- loadTemplates - Unchanged ---

func ParseContent

func ParseContent(contentDir string, site *SiteInfo, buildTarget string, outputDir string) error

--- parseContent - Unchanged --- Uses the globally configured `md` variable which now includes the Table extension.

func RenderPages

func RenderPages(site *SiteInfo, outputDir string, buildTarget string) error

--- renderPages - Unchanged --- It now accepts the build target and passes it to the template context.

func ServeSite

func ServeSite(outputDir string, serverPort string)

--- serveSite - Unchanged --- serveSite starts a web server with explicit 404 handling for non-existent files.

Types

type Page

type Page struct {
	SourcePath    string                 // Original path in content/
	OutputPath    string                 // Target path in the specified output directory
	URL           string                 // Absolute URL path (e.g., "/chapter1/page1/") used for internal logic
	RelativeURL   string                 // Path relative to output root (e.g., "chapter1/page1/index.html") used by templates
	RelPathToRoot string                 // Path from page to root (e.g., "../../" or "/") used by templates
	Title         string                 // Page title from front matter
	Weight        int                    // Weight for ordering from front matter
	ContentHTML   template.HTML          // Processed HTML content from Markdown
	IsHome        bool                   // Is this the root _index.md?
	IsSection     bool                   // Is this an _index.md file (a section index)?
	FrontMatter   map[string]interface{} // Store all front matter
	Pages         []*Page                // Child pages (for sections), sorted by weight
	Section       *Page                  // Parent section page (nil for top-level sections/home)
	Site          *SiteInfo              // Link back to global site info
}

--- Structs (Page, SiteInfo) - Unchanged --- Page holds information about a single content file

type SiteInfo

type SiteInfo struct {
	Pages     map[string]*Page   // Map Absolute URLs to Pages for easy lookup
	Sections  []*Page            // Top-level sections (chapters) sorted by weight
	Templates *template.Template // Parsed HTML templates
}

SiteInfo holds global information about the site

Jump to

Keyboard shortcuts

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