content

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllTags

func AllTags(pages []*Page) []string

AllTags returns a deduplicated list of all tags across all pages.

func BuildTree

func BuildTree(pages []*Page)

BuildTree sets Parent, Children, and Ancestors for all pages. It builds the hierarchy based on permalinks.

func DepthFromPath

func DepthFromPath(contentDir, filePath string) int

DepthFromPath calculates depth: home=0, top-level pages/sections=1, nested=2, etc.

func HashFile

func HashFile(path string) (string, error)

HashFile computes SHA-256 of a file and returns hex string.

func KindFromPath

func KindFromPath(contentDir, filePath string) string

KindFromPath determines the page kind from its path.

func OutputPathFromPermalink(outputDir, permalink string) string

OutputPathFromPermalink converts a permalink to an output file path under outputDir.

func PermalinkFromPath

func PermalinkFromPath(contentDir, filePath, defaultLang string) (string, string)

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

func SectionFromPath(contentDir, filePath string) string

SectionFromPath extracts the top-level section name.

func TagCounts

func TagCounts(pages []*Page) map[string]int

TagCounts returns map[tag]count.

Types

type LoadOptions

type LoadOptions struct {
	ContentDir  string
	DefaultLang string
	OutputDir   string
}

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

func FilterBySection(pages []*Page, section string) []*Page

FilterBySection returns pages belonging to a specific section (not including section index itself).

func FilterByTag

func FilterByTag(pages []*Page, tag string) []*Page

FilterByTag returns all pages that have the given tag.

func FindByPermalink(pages []*Page, permalink string) *Page

FindByPermalink returns a page by its permalink.

func FindHome

func FindHome(pages []*Page) *Page

FindHome returns the home page (Kind=="home") or nil.

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

func ParseAndRender(filePath string) (*Page, error)

ParseAndRender reads a markdown file, parses frontmatter, and renders to HTML.

func RegularPages

func RegularPages(pages []*Page) []*Page

RegularPages returns pages with Kind=="page".

func SectionPages

func SectionPages(pages []*Page) []*Page

SectionPages returns section index pages (Kind=="section").

Jump to

Keyboard shortcuts

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