Documentation
¶
Index ¶
- func CompanionMarkdown(s *Site, p *content.Page) string
- func Filter(pages []*content.Page, predicate func(*content.Page) bool) []*content.Page
- func First(pages []*content.Page) *content.Page
- func GetDataAs[T any](s *Site, key string) T
- func GroupBySection(pages []*content.Page) map[string][]*content.Page
- func Last(pages []*content.Page) *content.Page
- func Limit(pages []*content.Page, n int) []*content.Page
- func Offset(pages []*content.Page, n int) []*content.Page
- func Paginate(pages []*content.Page, pageNum, perPage int) []*content.Page
- func Reverse(pages []*content.Page) []*content.Page
- func SortByDate(pages []*content.Page, ascending bool) []*content.Page
- func SortByTitle(pages []*content.Page) []*content.Page
- func SortByWeight(pages []*content.Page) []*content.Page
- type AssetsConfig
- type AtomAuthor
- type AtomEntry
- type AtomFLink
- type AtomFeed
- type AtomLink
- type BuildConfig
- type Config
- func (c *Config) AssetsInputPath(base string) string
- func (c *Config) AssetsOutputPath(base string) string
- func (c *Config) ContentPath(base string) string
- func (c *Config) DataPath(base string) string
- func (c *Config) OutputPath(base string) string
- func (c *Config) Save(path string) error
- func (c *Config) StaticPath(base string) string
- func (c *Config) Validate() error
- type ContentConfig
- type HighlightConfig
- type JSONFeed
- type JSONFeedItem
- type LLMsConfig
- type LLMsSectionConfig
- type MenuItem
- type MenuItemConfig
- type Paginator
- type RSSChannel
- type RSSFeed
- type RSSItem
- type Section
- type Site
- func (s *Site) AllMenus() []string
- func (s *Site) AllSections() []*Section
- func (s *Site) AllTags() map[string]int
- func (s *Site) Atom(pages []*content.Page, title, subtitle string) string
- func (s *Site) Build(ctx context.Context) error
- func (s *Site) BuildAssets(ctx context.Context) error
- func (s *Site) Clean() error
- func (s *Site) Default404() string
- func (s *Site) Feed() string
- func (s *Site) GenerateTemplComponents(ctx context.Context) error
- func (s *Site) GetData(key string) any
- func (s *Site) GetOutputPath(url string) string
- func (s *Site) GetSection(name string) *Section
- func (s *Site) GetTaxonomy(name string) *Taxonomy
- func (s *Site) GetTerm(taxonomy, termSlug string) *Term
- func (s *Site) JSON(pages []*content.Page, title, description string) string
- func (s *Site) LLMsFull() string
- func (s *Site) LLMsPages() []*content.Page
- func (s *Site) LLMsSectionNames() []string
- func (s *Site) LLMsTxt() string
- func (s *Site) Manifest() string
- func (s *Site) Menu(name string) []*MenuItem
- func (s *Site) MenuWithActive(name, currentURL string) []*MenuItem
- func (s *Site) OutputDir() string
- func (s *Site) PageByURL(url string) *content.Page
- func (s *Site) PagesByTag(tag string) []*content.Page
- func (s *Site) PagesByTaxonomy(taxonomy, termSlug string) []*content.Page
- func (s *Site) PagesInSection(sectionName string) []*content.Page
- func (s *Site) ProcessContent(ctx context.Context) error
- func (s *Site) RSS(pages []*content.Page, title, description string) string
- func (s *Site) RegularPages() []*content.Page
- func (s *Site) RegularPagesInSection(sectionName string) []*content.Page
- func (s *Site) RobotsTxt() string
- func (s *Site) RobotsTxtWithDisallow(disallowPaths []string) string
- func (s *Site) SectionNames() []string
- func (s *Site) SetBaseDir(dir string)
- func (s *Site) Sitemap() string
- func (s *Site) Tags() []*Term
- func (s *Site) TaxonomyTerms(name string) []*Term
- func (s *Site) TaxonomyTermsByName(name string) []*Term
- type SitemapURL
- type Taxonomy
- type Term
- type URLSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompanionMarkdown ¶ added in v1.0.0
CompanionMarkdown returns clean markdown for a page's companion .md file. It prepends a title heading if the raw content doesn't already start with one. If the page's frontmatter includes llms_data, the referenced data files are appended as YAML blocks, making data-driven page content available to LLMs.
func GetDataAs ¶
GetDataAs attempts to return data cast to a specific type Returns nil if not found or type assertion fails
func GroupBySection ¶
GroupBySection groups pages by their section
func Limit ¶
Limit returns the first n pages from the slice If n >= len(pages), returns the original slice
func SortByDate ¶
SortByDate returns a copy of pages sorted by date If ascending is true, oldest first; otherwise newest first
func SortByTitle ¶
SortByTitle returns a copy of pages sorted alphabetically by title
Types ¶
type AssetsConfig ¶
type AssetsConfig struct {
InputDir string `yaml:"inputDir"`
OutputDir string `yaml:"outputDir"`
Minify bool `yaml:"minify"`
Fingerprint bool `yaml:"fingerprint"`
}
AssetsConfig configures asset processing
type AtomAuthor ¶
type AtomAuthor struct {
Name string `xml:"name"`
}
AtomAuthor represents an author in an Atom feed
type AtomEntry ¶
type AtomEntry struct {
Title string `xml:"title"`
Link AtomFLink `xml:"link"`
ID string `xml:"id"`
Updated string `xml:"updated"`
Summary string `xml:"summary,omitempty"`
Author *AtomAuthor `xml:"author,omitempty"`
}
AtomEntry represents an entry in an Atom feed
type AtomFLink ¶
type AtomFLink struct {
Href string `xml:"href,attr"`
Rel string `xml:"rel,attr,omitempty"`
Type string `xml:"type,attr,omitempty"`
}
AtomFLink represents a link in an Atom feed
type AtomFeed ¶
type AtomFeed struct {
XMLName xml.Name `xml:"feed"`
Xmlns string `xml:"xmlns,attr"`
Title string `xml:"title"`
Link []AtomFLink `xml:"link"`
Updated string `xml:"updated"`
ID string `xml:"id"`
Author *AtomAuthor `xml:"author,omitempty"`
Entries []AtomEntry `xml:"entry"`
}
AtomFeed represents an Atom 1.0 feed
type AtomLink ¶
type AtomLink struct {
Href string `xml:"href,attr"`
Rel string `xml:"rel,attr"`
Type string `xml:"type,attr"`
}
AtomLink represents the atom:link element for RSS feed self-reference
type BuildConfig ¶
type BuildConfig struct {
// Drafts includes draft pages in the build when true
Drafts bool `yaml:"drafts,omitempty"`
// Future includes pages with future dates when true
Future bool `yaml:"future,omitempty"`
}
BuildConfig contains build-time options
type Config ¶
type Config struct {
Title string `yaml:"title"`
BaseURL string `yaml:"baseURL"`
Description string `yaml:"description,omitempty"`
Language string `yaml:"language,omitempty"`
Content ContentConfig `yaml:"content"`
Assets AssetsConfig `yaml:"assets"`
OutputDir string `yaml:"outputDir"`
ThemeColor string `yaml:"themeColor,omitempty"`
// Taxonomies lists the taxonomy names to build (e.g., ["tags", "categories"])
// Each taxonomy extracts terms from page frontmatter with the same key
Taxonomies []string `yaml:"taxonomies,omitempty"`
// Menus defines navigation menus (e.g., "main", "footer")
Menus map[string][]MenuItemConfig `yaml:"menus,omitempty"`
// DataDir is the directory containing data files (YAML/JSON)
DataDir string `yaml:"dataDir,omitempty"`
// StaticDir is the directory containing files to copy to the output root
// (favicons, etc.). Defaults to "static".
StaticDir string `yaml:"staticDir,omitempty"`
// Build contains build-time options
Build BuildConfig `yaml:"build,omitempty"`
// Highlight configures syntax highlighting for code blocks
Highlight HighlightConfig `yaml:"highlight,omitempty"`
// Params holds arbitrary user-defined parameters accessible in templates
// via s.Config.Params["key"]. Environment overrides merge into this map.
Params map[string]any `yaml:"params,omitempty"`
// LLMs configures llms.txt generation for LLM-friendly content discovery
LLMs LLMsConfig `yaml:"llms,omitempty"`
}
Config represents the site configuration
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a configuration with sensible defaults
func LoadConfig ¶
LoadConfig loads configuration from a YAML file
func LoadConfigOrDefault ¶
LoadConfigOrDefault loads configuration or returns defaults if file doesn't exist
func LoadConfigWithEnv ¶
LoadConfigWithEnv loads the base config and merges an environment-specific override file on top of it. For example, with basePath "config.yaml" and env "production", it looks for "config.production.yaml" in the same directory. If env is empty, behaves identically to LoadConfig. If the env override file does not exist, the base config is used without error.
func (*Config) AssetsInputPath ¶
AssetsInputPath returns the absolute path to the assets input directory
func (*Config) AssetsOutputPath ¶
AssetsOutputPath returns the absolute path to the assets output directory
func (*Config) ContentPath ¶
ContentPath returns the absolute path to the content directory
func (*Config) OutputPath ¶
OutputPath returns the absolute path to the output directory
func (*Config) StaticPath ¶
StaticPath returns the absolute path to the static directory
type ContentConfig ¶
ContentConfig configures content processing
type HighlightConfig ¶
type HighlightConfig struct {
// Style is the Chroma style name (e.g., "monokai", "github", "dracula").
// When set, code blocks are syntax-highlighted and a chroma.css file is generated.
// Empty string disables syntax highlighting.
Style string `yaml:"style,omitempty"`
// LineNumbers adds line numbers to code blocks when true
LineNumbers bool `yaml:"lineNumbers,omitempty"`
}
HighlightConfig configures syntax highlighting for code blocks
type JSONFeed ¶
type JSONFeed struct {
Version string `json:"version"`
Title string `json:"title"`
HomePageURL string `json:"home_page_url"`
FeedURL string `json:"feed_url"`
Description string `json:"description,omitempty"`
Language string `json:"language,omitempty"`
Items []JSONFeedItem `json:"items"`
}
JSONFeed represents a JSON Feed 1.1
type JSONFeedItem ¶
type JSONFeedItem struct {
ID string `json:"id"`
URL string `json:"url"`
Title string `json:"title"`
ContentText string `json:"content_text,omitempty"`
Summary string `json:"summary,omitempty"`
DatePublished string `json:"date_published,omitempty"`
Author *struct {
Name string `json:"name"`
} `json:"author,omitempty"`
}
JSONFeedItem represents an item in a JSON Feed
type LLMsConfig ¶ added in v1.0.0
type LLMsConfig struct {
// Enabled turns on llms.txt generation
Enabled bool `yaml:"enabled"`
// Description overrides the site description in the llms.txt blockquote
Description string `yaml:"description,omitempty"`
// Sections defines explicit content sections for llms.txt.
// If empty, sections are auto-derived from the site's directory structure.
Sections []LLMsSectionConfig `yaml:"sections,omitempty"`
// Exclude lists section patterns to exclude from llms.txt (e.g., "internal")
Exclude []string `yaml:"exclude,omitempty"`
}
LLMsConfig configures llms.txt generation for LLM-friendly content discovery. When Enabled is true, the build generates llms.txt, llms-full.txt, and companion .md files alongside each HTML page.
type LLMsSectionConfig ¶ added in v1.0.0
type LLMsSectionConfig struct {
// Name is the display name for the section heading
Name string `yaml:"name"`
// Pattern is the section name (content directory) to match
Pattern string `yaml:"pattern"`
// Priority is "required" (default) or "optional".
// Optional sections are grouped under "## Optional" in the output.
Priority string `yaml:"priority,omitempty"`
}
LLMsSectionConfig defines a section in the llms.txt output.
type MenuItem ¶
type MenuItem struct {
Name string
URL string
Weight int
Active bool // Set during rendering based on current page
}
MenuItem represents a menu item with runtime state
type MenuItemConfig ¶
type MenuItemConfig struct {
Name string `yaml:"name"`
URL string `yaml:"url"`
Weight int `yaml:"weight,omitempty"`
}
MenuItemConfig represents a menu item in configuration
type Paginator ¶
type Paginator struct {
Items []*content.Page // pages for current page
TotalItems int // total number of items across all pages
PerPage int // items per page
TotalPages int // total number of pages
PageNum int // current page number (1-indexed)
HasPrev bool // true if there's a previous page
HasNext bool // true if there's a next page
PrevURL string // URL of previous page (empty if no prev)
NextURL string // URL of next page (empty if no next)
PageURLs []string // URLs for all pages (for building navigation)
BaseURL string // base URL for this paginated section
}
Paginator handles pagination of page collections with navigation URLs
func NewPaginator ¶
NewPaginator creates a paginator for a page collection baseURL should end with a slash (e.g., "/blog/")
func (*Paginator) Page ¶
Page returns a new paginator configured for a specific page number (1-indexed) The returned paginator has Items set to just the items for that page
type RSSChannel ¶
type RSSChannel struct {
Title string `xml:"title"`
Link string `xml:"link"`
Description string `xml:"description"`
Language string `xml:"language,omitempty"`
LastBuildDate string `xml:"lastBuildDate,omitempty"`
AtomLink AtomLink `xml:"atom:link"`
Items []RSSItem `xml:"item"`
}
RSSChannel represents the channel element of an RSS feed
type RSSFeed ¶
type RSSFeed struct {
XMLName xml.Name `xml:"rss"`
Version string `xml:"version,attr"`
Atom string `xml:"xmlns:atom,attr"`
Channel RSSChannel `xml:"channel"`
}
RSSFeed represents an RSS 2.0 feed
type RSSItem ¶
type RSSItem struct {
Title string `xml:"title"`
Link string `xml:"link"`
Description string `xml:"description,omitempty"`
PubDate string `xml:"pubDate,omitempty"`
GUID string `xml:"guid"`
Author string `xml:"author,omitempty"`
}
RSSItem represents an item in an RSS feed
type Section ¶
type Section struct {
// Name is the section identifier (directory name)
Name string
// Title is the display title (from _index.md or derived from Name)
Title string
// Description is from _index.md frontmatter
Description string
// Pages contains all pages in this section, sorted by date descending
Pages []*content.Page
// URL is the section's URL path (e.g., /blog/)
URL string
// Index is the _index.md page for this section (if it exists)
Index *content.Page
}
Section represents a content section (e.g., blog, docs)
func (*Section) RegularPages ¶
RegularPages returns pages excluding _index.md
type Site ¶
type Site struct {
Config *Config
Pages []*content.Page
Sections map[string]*Section
Taxonomies map[string]*Taxonomy
Menus map[string][]*MenuItem
Data map[string]any
BuildTime time.Time
AssetVersion string // content hash for cache-busting query strings
// contains filtered or unexported fields
}
Site represents a static site with all its content and configuration
func NewWithConfig ¶
NewWithConfig creates a new Site with an existing configuration
func NewWithEnv ¶
NewWithEnv creates a new Site, merging an environment-specific config override. For example, NewWithEnv("config.yaml", "production") loads config.yaml then merges config.production.yaml on top. If env is empty, behaves like New().
func (*Site) AllSections ¶
AllSections returns all sections (excluding _root if empty)
func (*Site) BuildAssets ¶
BuildAssets builds all assets (CSS, JS, static files)
func (*Site) Default404 ¶
Default404 generates a minimal 404 page as a fallback. Users can override this by creating content/404.md or placing 404.html in static/.
func (*Site) GenerateTemplComponents ¶
GenerateTemplComponents runs templ generate on the components directory
func (*Site) GetData ¶
GetData returns data by key, supporting nested paths with "/" For example: GetData("team") or GetData("config/settings")
func (*Site) GetOutputPath ¶
GetOutputPath converts a URL path to a filesystem output path This is a helper for user's rendering code
func (*Site) GetSection ¶
GetSection returns a section by name
func (*Site) GetTaxonomy ¶
GetTaxonomy returns a taxonomy by name, or nil if not found
func (*Site) LLMsFull ¶ added in v1.0.0
LLMsFull generates /llms-full.txt with all linked content inlined.
func (*Site) LLMsPages ¶ added in v1.0.0
LLMsPages returns all pages that would be included in llms.txt output, respecting exclusion rules. Useful for templates or custom rendering.
func (*Site) LLMsSectionNames ¶ added in v1.0.0
LLMsSectionNames returns the section names that will appear in llms.txt, either from config or auto-derived. Useful for debugging configuration.
func (*Site) LLMsTxt ¶ added in v1.0.0
LLMsTxt generates the /llms.txt index file following the llms.txt specification. It produces an H1 title, blockquote summary, and H2 sections with links to companion markdown files for each published page.
func (*Site) MenuWithActive ¶
MenuWithActive returns a menu with the Active flag set for the current URL This returns a new slice to avoid mutating the original
func (*Site) OutputDir ¶
OutputDir returns the absolute path to the output directory This is a helper for code that needs the output directory path
func (*Site) PagesByTag ¶
PagesByTag returns all published pages with a specific tag Uses the taxonomy system if available, falls back to direct tag check
func (*Site) PagesByTaxonomy ¶
PagesByTaxonomy returns pages for a specific taxonomy term Returns nil if taxonomy or term doesn't exist
func (*Site) PagesInSection ¶
PagesInSection returns all pages in a specific section Returns nil if section doesn't exist
func (*Site) ProcessContent ¶
ProcessContent processes all content files and makes them available via Pages
func (*Site) RegularPages ¶
RegularPages returns all non-index, published pages across all sections
func (*Site) RegularPagesInSection ¶
RegularPagesInSection returns non-index, published pages in a section
func (*Site) RobotsTxtWithDisallow ¶
RobotsTxtWithDisallow generates a robots.txt with custom disallow rules
func (*Site) SectionNames ¶
SectionNames returns names of all sections with content
func (*Site) SetBaseDir ¶
SetBaseDir sets the base directory for the site
func (*Site) Tags ¶
Tags returns all tags as Term structs, sorted by page count descending This is a convenience method equivalent to TaxonomyTerms("tags")
func (*Site) TaxonomyTerms ¶
TaxonomyTerms returns all terms for a taxonomy, sorted by page count descending Returns nil if taxonomy doesn't exist
func (*Site) TaxonomyTermsByName ¶
TaxonomyTermsByName returns all terms for a taxonomy, sorted alphabetically
type SitemapURL ¶
type SitemapURL struct {
Loc string `xml:"loc"`
LastMod string `xml:"lastmod,omitempty"`
ChangeFreq string `xml:"changefreq,omitempty"`
Priority string `xml:"priority,omitempty"`
}
SitemapURL represents a single URL entry in a sitemap
type Taxonomy ¶
type Taxonomy struct {
// Name is the taxonomy identifier (e.g., "tags")
Name string
// Plural is used for URLs (usually same as Name)
Plural string
// Terms maps term slugs to Term structs
Terms map[string]*Term
}
Taxonomy represents a classification system (e.g., tags, categories)
func NewTaxonomy ¶
NewTaxonomy creates a new taxonomy with the given name
func (*Taxonomy) SortTermPages ¶
func (t *Taxonomy) SortTermPages()
SortTermPages sorts pages within each term by date descending
func (*Taxonomy) TermsByName ¶
TermsByName returns all terms sorted alphabetically by name
type Term ¶
type Term struct {
// Name is the display name of the term
Name string
// Slug is the URL-safe version of the name
Slug string
// Pages contains all pages with this term
Pages []*content.Page
// URL is the term's URL path (e.g., /tags/go/)
URL string
// Taxonomy is the parent taxonomy name
Taxonomy string
}
Term represents a single term within a taxonomy (e.g., "go" in tags)