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 ¶
- func CopyDir(srcDir, dstDir string) error
- func GenerateFeeds(outDir, baseURL, siteTitle string, articles []*model.ProcessedArticle) error
- func GenerateSitemap(outDir, baseURL string, articles []*model.ProcessedArticle, cfg model.Config) error
- type HTMLGenerator
- type OGPGenerator
- type OutputGenerator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.
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.
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.