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, ...) error
- func TaxonomyURLs(site *model.Site, cfg model.Config) []string
- 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, cfg model.Config) 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. When cfg has I18n.Locales configured, per-locale feeds are also written:
{locale}/feed.xml and {locale}/atom.xml for each non-default locale.
The root feed.xml / atom.xml contain only articles from the default locale (or all articles when i18n is not configured).
func GenerateSitemap ¶
func GenerateSitemap(outDir, baseURL string, articles []*model.ProcessedArticle, virtualPages []*model.VirtualPage, extraURLs []string, cfg model.Config) error
GenerateSitemap writes sitemap.xml to outDir, listing all article URLs, virtual pages produced by SitePlugins (e.g. /bookshelf/), and any extra URL paths supplied via extraURLs (e.g. taxonomy and archive pages). 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.
func TaxonomyURLs ¶ added in v1.0.17
TaxonomyURLs returns the canonical URL paths (with trailing slash) for all page-1 taxonomy and archive listing pages generated by this site. Pagination sub-pages (/page/N/) are intentionally excluded. Returned paths are relative to the site root, e.g. "/tags/go/", "/categories/architecture/", "/archives/2024/", "/archives/2024/01/".
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, contentDir string, cfg model.OGPConfig) *OGPGenerator
NewOGPGenerator returns an OGPGenerator configured from cfg. contentDir should be the absolute path to the content directory so that article FilePaths (absolute) can be matched against changeSet entries (relative to contentDir). Pass "" to disable that conversion.
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.