generator

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package generator writes rendered HTML, assets, sitemaps, and feeds to the output directory.

Package generator writes rendered HTML, assets, sitemap, and Atom feed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyAssets

func CopyAssets(srcDir, dstDir string) error

CopyAssets recursively copies all files from srcDir into dstDir.

func GenerateFeeds

func GenerateFeeds(outDir, baseURL, siteTitle string, articles []*model.ProcessedArticle) error

GenerateFeeds writes feed.xml (RSS 2.0) and atom.xml (Atom 1.0) to outDir. Articles are sorted newest-first. baseURL must not have a trailing slash.

func GenerateSitemap

func GenerateSitemap(outDir, baseURL string, articles []*model.ProcessedArticle, cfg model.Config) error

GenerateSitemap writes sitemap.xml to outDir, listing all article URLs. When articles have Translations populated (i18n), xhtml:link hreflang alternates are included for SEO. Articles are sorted newest-first. baseURL must not have a trailing slash. When cfg has I18n.Locales configured, the locale index pages (/ and /ja/ etc.) are prepended to the sitemap as important entry points.

Types

type HTMLGenerator

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

HTMLGenerator satisfies OutputGenerator by writing HTML pages and assets.

func NewHTMLGenerator

func NewHTMLGenerator(outDir string, engine gohantemplate.TemplateEngine, cfg model.Config) *HTMLGenerator

NewHTMLGenerator returns an HTMLGenerator that writes to outDir.

func (*HTMLGenerator) Generate

func (g *HTMLGenerator) Generate(site *model.Site, changeSet *model.ChangeSet) error

Generate writes all HTML pages and copies static assets. When changeSet is nil every page is written; otherwise only affected pages.

type OGPGenerator

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

OGPGenerator generates OGP thumbnail images for articles at build time.

func NewOGPGenerator

func NewOGPGenerator(outDir string, cfg model.OGPConfig) *OGPGenerator

NewOGPGenerator returns an OGPGenerator configured from cfg.

func (*OGPGenerator) Generate

func (g *OGPGenerator) Generate(site *model.Site, changeSet *model.ChangeSet) error

Generate creates one PNG per article in public/ogp/{slug}.png. Articles whose output file already exists are skipped when changeSet is non-nil and the article is not in the changed set.

type OutputGenerator

type OutputGenerator interface {
	// Generate writes all HTML pages, copies static assets, and generates OGP
	// images into outDir.  Only files in changeSet (or all files when changeSet
	// is nil) are written.
	Generate(site *model.Site, changeSet *model.ChangeSet) error
}

OutputGenerator takes the fully-rendered site data and writes all output files to the configured output directory.

Sitemap and feed generation are handled by the package-level GenerateSitemap and GenerateFeeds functions, which are i18n-aware and kept separate from the HTML generation step.

Jump to

Keyboard shortcuts

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