}
ps.markdownTitleInfo = mi
+ // Append taxonomies and categories
+ gpi, err := s.h.gitPurismInfoForPage(ps)
+ if err != nil {
+ return nil, errors.Wrap(err, "failed to load GitPurism data")
+ }
+ ps.gitPurismInfo = gpi
+
r, err := content()
if err != nil {
return nil, err
return nil, ps.wrapError(err)
}
+ if (metaProvider.params["tags"] != nil) {
+ metaProvider.params["tags"] = append(metaProvider.params["tags"].([]string), gpi.Tags...)
+ } else {
+ metaProvider.params["tags"] = gpi.Tags
+ }
+
+ if (metaProvider.params["categories"] != nil) {
+ metaProvider.params["categories"] = append(metaProvider.params["tags"].([]string), gpi.Categories...)
+ } else {
+ metaProvider.params["categories"] = gpi.Categories
+ }
+
if err := metaProvider.applyDefaultValues(n); err != nil {
return nil, err
}
markdownTitleInfo *markdownTitleInfo
+ gitPurismInfo *gitPurismInfo
+
// As loaded from the /data dirs
data map[string]any
gitInfo *lazy.Init
markdownTitleInfo *lazy.Init
+ gitPurismInfo *lazy.Init
// Maps page translations.
translations *lazy.Init
h.layouts.Reset()
h.gitInfo.Reset()
h.markdownTitleInfo.Reset()
+ h.gitPurismInfo.Reset()
h.translations.Reset()
}
return h.markdownTitleInfo.forPage(p), nil
}
+func (h *HugoSites) gitPurismInfoForPage(p page.Page) (*GitPurismInfo, error) {
+ if _, err := h.init.gitPurismInfo.Do(); err != nil {
+ return nil, err
+ }
+
+ if h.gitPurismInfo == nil {
+ return nil, nil
+ }
+
+ return h.gitPurismInfo.forPage(p), nil
+}
+
func (h *HugoSites) siteInfos() page.Sites {
infos := make(page.Sites, len(h.Sites))
for i, site := range h.Sites {
layouts: lazy.New(),
gitInfo: lazy.New(),
markdownTitleInfo: lazy.New(),
+ gitPurismInfo: lazy.New(),
translations: lazy.New(),
},
}
return nil, nil
})
+ h.init.gitPurismInfo.Add(func() (any, error) {
+ err := h.loadGitPurismInfo()
+ if err != nil {
+ return nil, errors.Wrap(err, "failed to load MarkdownTitle info")
+ }
+ return nil, nil
+ })
+
for _, s := range sites {
s.h = h
}
return nil
}
+func (h *HugoSites) loadGitPurismInfo() error {
+ if h.Cfg.GetBool("enableGitPurismInfo") {
+ gpi, err := newGitPurismInfo(h.Cfg)
+ if err != nil {
+ h.Log.Errorln("Failed to read GitPurismInfo:", err)
+ } else {
+ h.gitPurismInfo = gpi
+ }
+ }
+ return nil
+}
+
func (l configLoader) applyDeps(cfg deps.DepsCfg, sites ...*Site) error {
if cfg.TemplateProvider == nil {
cfg.TemplateProvider = tplimpl.DefaultTemplateProvider