Documentation
¶
Index ¶
- func AllTags(pages []*Page) []string
- func BuildTree(pages []*Page)
- func DepthFromPath(contentDir, filePath string) int
- func HashFile(path string) (string, error)
- func KindFromPath(contentDir, filePath string) string
- func OutputPathFromPermalink(outputDir, permalink string) string
- func PermalinkFromPath(contentDir, filePath, defaultLang string) (string, string)
- func SectionFromPath(contentDir, filePath string) string
- func TagCounts(pages []*Page) map[string]int
- type LoadOptions
- type Page
- func FilterBySection(pages []*Page, section string) []*Page
- func FilterByTag(pages []*Page, tag string) []*Page
- func FindByPermalink(pages []*Page, permalink string) *Page
- func FindHome(pages []*Page) *Page
- func LoadAll(opts LoadOptions) ([]*Page, error)
- func ParseAndRender(filePath string) (*Page, error)
- func RegularPages(pages []*Page) []*Page
- func SectionPages(pages []*Page) []*Page
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildTree ¶
func BuildTree(pages []*Page)
BuildTree sets Parent, Children, and Ancestors for all pages. It builds the hierarchy based on permalinks.
func DepthFromPath ¶
DepthFromPath calculates depth: home=0, top-level pages/sections=1, nested=2, etc.
func KindFromPath ¶
KindFromPath determines the page kind from its path.
func OutputPathFromPermalink ¶
OutputPathFromPermalink converts a permalink to an output file path under outputDir.
func PermalinkFromPath ¶
PermalinkFromPath derives the permalink from file path + lang + content root. contentDir: root content directory filePath: absolute path to the .md file defaultLang: language that gets no URL prefix (usually "en")
func SectionFromPath ¶
SectionFromPath extracts the top-level section name.
Types ¶
type LoadOptions ¶
LoadOptions configures the content loader.
type Page ¶
type Page struct {
FilePath string
FileHash string
RelPermalink string
OutputPath string
Title string
LinkTitle string
Description string
Date time.Time
Tags []string
Draft bool
Weight int
Type string
NoIndex bool
ExcludeSearch bool
Params map[string]any
Kind string // "page"|"section"|"home"|"term"|"taxonomy"|"special"
Lang string
Section string
Depth int
Parent *Page
Children []*Page
Ancestors []*Page
ContentHTML string
ContentPlain string // plain text version for search
Summary string
ReadingTime int
WordCount int
}
Page represents a single content page or section.
func FilterBySection ¶
FilterBySection returns pages belonging to a specific section (not including section index itself).
func FilterByTag ¶
FilterByTag returns all pages that have the given tag.
func FindByPermalink ¶
FindByPermalink returns a page by its permalink.
func LoadAll ¶
func LoadAll(opts LoadOptions) ([]*Page, error)
LoadAll walks contentDir, parses all markdown files, and builds the page tree. It returns all pages including the home page and section indexes.
func ParseAndRender ¶
ParseAndRender reads a markdown file, parses frontmatter, and renders to HTML.
func RegularPages ¶
RegularPages returns pages with Kind=="page".
func SectionPages ¶
SectionPages returns section index pages (Kind=="section").