Documentation
¶
Index ¶
- Variables
- func AllTags(pages []*Page) []string
- func ApplySlugURL(base string, page *Page) string
- 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
- func WriteChromaCSS(path string) (string, error)
- type LoadOptions
- type Page
- func BuildTree(pages []*Page) []*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
- func (p *Page) Content() template.HTML
- func (p *Page) ContentBaseName() string
- func (p *Page) FuzzyWordCount() int
- func (p *Page) IsHome() bool
- func (p *Page) IsNode() bool
- func (p *Page) IsPage() bool
- func (p *Page) IsSection() bool
- func (p *Page) Pages() []*Page
- func (p *Page) Paginator() any
- func (p *Page) Path() string
- func (p *Page) Plain() string
- func (p *Page) RegularPages() []*Page
- func (p *Page) Resources() *PageResourcesStub
- func (p *Page) Sections() []*Page
- func (p *Page) Store() *PageScratch
- type PageResourcesStub
- type PageScratch
Constants ¶
This section is empty.
Variables ¶
var SyntaxHighlight bool
SyntaxHighlight controls whether Chroma server-side syntax highlighting is enabled.
Functions ¶
func ApplySlugURL ¶ added in v0.2.0
ApplySlugURL applies slug and url front matter overrides to a base permalink. page.Kind must be set before calling.
func DepthFromPath ¶
DepthFromPath calculates depth: home=0, top-level=1, nested=2, etc.
func KindFromPath ¶
KindFromPath determines the page kind from its file path.
func OutputPathFromPermalink ¶
OutputPathFromPermalink converts a permalink to an output file path.
func PermalinkFromPath ¶
PermalinkFromPath derives the base permalink from a file path.
func SectionFromPath ¶
SectionFromPath extracts the top-level section name.
func WriteChromaCSS ¶ added in v0.2.0
WriteChromaCSS writes a combined light+dark syntax-highlight stylesheet.
Types ¶
type LoadOptions ¶
LoadOptions configures the content loader.
type Page ¶
type Page struct {
FilePath string
FileHash string
FileSize int64
FileMtime int64
// URL fields
RelPermalink string
Permalink string // full URL with base URL (set by build)
OutputPath string
Slug string // front matter slug: overrides last URL segment
URL string // front matter url: overrides entire permalink
Aliases []string // redirect aliases
// Core metadata
Title string
LinkTitle string
Description string
Summary string
Date time.Time
PublishDate time.Time
ExpiryDate time.Time
Lastmod time.Time
Draft bool
Weight int
Type string // content type: front matter or root section name
Layout string // explicit template name override
// Taxonomy fields
Tags []string
Categories []string
Keywords []string
Taxonomies map[string][]string // plural name -> terms
// Visibility
NoIndex bool
ExcludeSearch bool
// Arbitrary front matter params
Params map[string]any
// Cascade: front matter values to inherit down to descendant pages.
// Only set on section/home pages. Applied in BuildTree.
Cascade map[string]any
// Page classification
Kind string // "page"|"section"|"home"|"term"|"taxonomy"
Lang string
Section string // root section name (first dir under content/)
Depth int
// Tree structure
Parent *Page
Children []*Page
Ancestors []*Page
// Siblings (populated by build after tree is built)
NextPage *Page
PrevPage *Page
// Rendered content
ContentHTML string
ContentPlain string
ReadingTime int
WordCount int
}
Page represents a single content page or section.
func BuildTree ¶
BuildTree sets Parent, Children, and Ancestors for all pages. It builds the hierarchy based on permalinks.
It also synthesizes in-memory section pages for any directory that holds content but has no _index.md, mirroring Hugo, which creates a section for every such directory. Without this, a page nested under a dir with no _index.md would have no parent and drop out of .RegularPagesRecursive even though it still renders as a standalone page. The synthesized sections are returned so the caller can finish them (output path, permalink) and add them to the render set; they carry an empty FilePath, which the build pipeline treats as always-render, never-cache.
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 front matter, and renders HTML.
func RegularPages ¶
RegularPages returns pages with Kind=="page".
func SectionPages ¶
SectionPages returns section index pages (Kind=="section").
func (*Page) Content ¶ added in v0.2.0
Content returns the HTML content for direct template access via .Page.Content.
func (*Page) ContentBaseName ¶ added in v0.2.0
ContentBaseName returns the base name of the content file (without extension).
func (*Page) FuzzyWordCount ¶ added in v0.2.0
FuzzyWordCount returns WordCount rounded to the nearest 100.
func (*Page) IsNode ¶ added in v0.2.0
IsNode reports whether this is a list page (home, section, taxonomy, term).
func (*Page) Paginator ¶ added in v0.2.0
Paginator returns nil (stub for Hugo .Paginator on content.Page — not available outside TemplateData context).
func (*Page) RegularPages ¶ added in v0.2.0
RegularPages returns only Kind=="page" children.
func (*Page) Resources ¶ added in v0.2.0
func (p *Page) Resources() *PageResourcesStub
Resources returns a stub resources object for this page.
func (*Page) Store ¶ added in v0.2.0
func (p *Page) Store() *PageScratch
Store returns a per-page scratch pad (Hugo 0.117+).
type PageResourcesStub ¶ added in v0.2.0
type PageResourcesStub struct{}
PageResourcesStub is a minimal stub for page-level resources (image processing etc). The actual resource implementation lives in pkg/render to avoid circular imports, but content.Page needs to expose Resources() for direct template access via .Page.Resources.
func (*PageResourcesStub) ByType ¶ added in v0.2.0
func (r *PageResourcesStub) ByType(t string) []any
func (*PageResourcesStub) Get ¶ added in v0.2.0
func (r *PageResourcesStub) Get(name string) any
func (*PageResourcesStub) GetMatch ¶ added in v0.2.0
func (r *PageResourcesStub) GetMatch(pattern string) any
func (*PageResourcesStub) Match ¶ added in v0.2.0
func (r *PageResourcesStub) Match(pattern string) []any
type PageScratch ¶ added in v0.2.0
type PageScratch struct {
// contains filtered or unexported fields
}
PageScratch is a lightweight scratch pad used by content.Page.Store.
func (*PageScratch) Delete ¶ added in v0.2.0
func (s *PageScratch) Delete(key string) string
func (*PageScratch) Get ¶ added in v0.2.0
func (s *PageScratch) Get(key string) any