output

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanOutputDir

func CleanOutputDir(dir string) error

CleanOutputDir removes all files from the output directory.

func ComputeOutputPath

func ComputeOutputPath(permalink string) string

ComputeOutputPath computes the output file path for a given permalink. Pretty URLs: /about/ → about/index.html, / → index.html

func GenerateSitemap

func GenerateSitemap(pages []*content.Page, cfg config.SitemapConfig, baseURL string) ([]byte, error)

GenerateSitemap creates a sitemap.xml from the published pages.

func RenderFeedTemplate

func RenderFeedTemplate(tmpl FeedTemplate, context map[string]interface{}) ([]byte, error)

RenderFeedTemplate renders a feed template with the appropriate context. Returns the raw template content with basic variable substitution.

func ResolveFormatLayout

func ResolveFormatLayout(page *content.Page, format string, layoutsDir string, engine string) (string, error)

ResolveFormatLayout finds the layout file for a specific output format. Lookup: layouts/<layout>.<format>.<engine-ext> → layouts/<layout>.<format>

func ResolveOutputFormat

func ResolveOutputFormat(page *content.Page) string

ResolveOutputFormat determines the output format for a page. Returns "html" as default; if the page has explicit outputs, returns the first one.

func ShouldWrite

func ShouldWrite(permalink string) bool

ShouldWrite returns false for pages with permalink: false (data-only pages that should be processed but not written to disk).

func WriteAliases

func WriteAliases(outputDir string, aliases []string, content []byte) error

WriteAliases writes the same rendered content to all alias output paths.

func WriteAliasesCached

func WriteAliasesCached(outputDir string, aliases []string, content []byte, dc *DirectoryCache) error

WriteAliasesCached is like WriteAliases but uses a DirectoryCache.

func WriteFile

func WriteFile(outputDir, relPath string, content []byte) error

WriteFile writes content to the output directory at the given relative path.

func WriteFileCached

func WriteFileCached(outputDir, relPath string, content []byte, dc *DirectoryCache) error

WriteFileCached is like WriteFile but uses a DirectoryCache to skip redundant os.MkdirAll calls when many files share the same directory.

func WritePageFormats

func WritePageFormats(outputDir string, permalink string, formats map[string][]byte) error

WritePageFormats writes a page's content in multiple output formats.

Types

type DirectoryCache

type DirectoryCache struct {
	// contains filtered or unexported fields
}

DirectoryCache tracks which directories have been created so that repeated calls for the same directory skip the os.MkdirAll syscall.

func NewDirectoryCache

func NewDirectoryCache() *DirectoryCache

NewDirectoryCache returns a ready-to-use DirectoryCache.

func (*DirectoryCache) EnsureDir

func (dc *DirectoryCache) EnsureDir(dir string) error

EnsureDir creates dir (and parents) if it hasn't been created yet.

type FeedTemplate

type FeedTemplate struct {
	TemplatePath string // Path to the feed template file
	OutputPath   string // Computed output path
	Section      string // Section scope (empty = site-wide)
	Taxonomy     string // Taxonomy scope (empty = not taxonomy)
	Term         string // Taxonomy term (empty = all terms)
}

FeedTemplate represents a discovered feed template and its output context.

func ResolveFeedTemplates

func ResolveFeedTemplates(layoutsDir string) ([]FeedTemplate, error)

ResolveFeedTemplates scans the layouts directory for feed templates. Template placement determines the feed's output path and context:

  • layouts/feed.xml → /feed.xml (site-wide feed)
  • layouts/blog/feed.xml → /blog/feed.xml (section feed)
  • layouts/taxonomies/tags/feed.xml → /tags/:slug/feed.xml (per-term)

Jump to

Keyboard shortcuts

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