diff options
Diffstat (limited to 'hugolib/page__meta.go')
-rw-r--r-- | hugolib/page__meta.go | 56 |
1 files changed, 22 insertions, 34 deletions
diff --git a/hugolib/page__meta.go b/hugolib/page__meta.go index bb038a1d9..7ad2a8d51 100644 --- a/hugolib/page__meta.go +++ b/hugolib/page__meta.go @@ -116,7 +116,7 @@ type pageMeta struct { sections []string // Sitemap overrides from front matter. - sitemap config.Sitemap + sitemap config.SitemapConfig s *Site @@ -139,24 +139,8 @@ func (p *pageMeta) Author() page.Author { } func (p *pageMeta) Authors() page.AuthorList { - helpers.Deprecated(".Authors", "Use taxonomies.", false) - authorKeys, ok := p.params["authors"] - if !ok { - return page.AuthorList{} - } - authors := authorKeys.([]string) - if len(authors) < 1 || len(p.s.Info.Authors) < 1 { - return page.AuthorList{} - } - - al := make(page.AuthorList) - for _, author := range authors { - a, ok := p.s.Info.Authors[author] - if ok { - al[author] = a - } - } - return al + helpers.Deprecated(".Authors", "Use taxonomies.", true) + return nil } func (p *pageMeta) BundleType() files.ContentClass { @@ -224,7 +208,7 @@ func (p *pageMeta) IsPage() bool { // This method is also implemented on SiteInfo. // TODO(bep) interface func (p *pageMeta) Param(key any) (any, error) { - return resource.Param(p, p.s.Info.Params(), key) + return resource.Param(p, p.s.Params(), key) } func (p *pageMeta) Params() maps.Params { @@ -298,7 +282,7 @@ func (p *pageMeta) SectionsPath() string { return path.Join(p.SectionsEntries()...) } -func (p *pageMeta) Sitemap() config.Sitemap { +func (p *pageMeta) Sitemap() config.SitemapConfig { return p.sitemap } @@ -502,17 +486,19 @@ func (pm *pageMeta) setMetadata(parentBucket *pagesMapBucket, p *pageState, fron } case "outputs": o := cast.ToStringSlice(v) + // lower case names: + for i, s := range o { + o[i] = strings.ToLower(s) + } if len(o) > 0 { // Output formats are explicitly set in front matter, use those. - outFormats, err := p.s.outputFormatsConfig.GetByNames(o...) - + outFormats, err := p.s.conf.OutputFormats.Config.GetByNames(o...) if err != nil { p.s.Log.Errorf("Failed to resolve output formats: %s", err) } else { pm.configuredOutputFormats = outFormats pm.params[loki] = outFormats } - } case "draft": draft = new(bool) @@ -536,7 +522,10 @@ func (pm *pageMeta) setMetadata(parentBucket *pagesMapBucket, p *pageState, fron } pm.params[loki] = pm.aliases case "sitemap": - p.m.sitemap = config.DecodeSitemap(p.s.siteCfg.sitemap, maps.ToStringMap(v)) + p.m.sitemap, err = config.DecodeSitemap(p.s.conf.Sitemap, maps.ToStringMap(v)) + if err != nil { + return fmt.Errorf("failed to decode sitemap config in front matter: %s", err) + } pm.params[loki] = p.m.sitemap sitemapSet = true case "iscjklanguage": @@ -575,7 +564,6 @@ func (pm *pageMeta) setMetadata(parentBucket *pagesMapBucket, p *pageState, fron break } fallthrough - default: // If not one of the explicit values, store in Params switch vv := v.(type) { @@ -601,6 +589,7 @@ func (pm *pageMeta) setMetadata(parentBucket *pagesMapBucket, p *pageState, fron } else { pm.params[loki] = []string{} } + default: pm.params[loki] = vv } @@ -608,7 +597,7 @@ func (pm *pageMeta) setMetadata(parentBucket *pagesMapBucket, p *pageState, fron } if !sitemapSet { - pm.sitemap = p.s.siteCfg.sitemap + pm.sitemap = p.s.conf.Sitemap } pm.markup = p.s.ContentSpec.ResolveMarkup(pm.markup) @@ -625,7 +614,7 @@ func (pm *pageMeta) setMetadata(parentBucket *pagesMapBucket, p *pageState, fron if isCJKLanguage != nil { pm.isCJKLanguage = *isCJKLanguage - } else if p.s.siteCfg.hasCJKLanguage && p.source.parsed != nil { + } else if p.s.conf.HasCJKLanguage && p.source.parsed != nil { if cjkRe.Match(p.source.parsed.Input()) { pm.isCJKLanguage = true } else { @@ -692,7 +681,7 @@ func (p *pageMeta) applyDefaultValues(n *contentNode) error { if p.title == "" && p.f.IsZero() { switch p.Kind() { case page.KindHome: - p.title = p.s.Info.title + p.title = p.s.Title() case page.KindSection: var sectionName string if n != nil { @@ -702,7 +691,7 @@ func (p *pageMeta) applyDefaultValues(n *contentNode) error { } sectionName = helpers.FirstUpper(sectionName) - if p.s.Cfg.GetBool("pluralizeListTitles") { + if p.s.conf.PluralizeListTitles { p.title = flect.Pluralize(sectionName) } else { p.title = sectionName @@ -710,9 +699,9 @@ func (p *pageMeta) applyDefaultValues(n *contentNode) error { case page.KindTerm: // TODO(bep) improve key := p.sections[len(p.sections)-1] - p.title = strings.Replace(p.s.titleFunc(key), "-", " ", -1) + p.title = strings.Replace(p.s.conf.C.CreateTitle(key), "-", " ", -1) case page.KindTaxonomy: - p.title = p.s.titleFunc(p.sections[0]) + p.title = p.s.conf.C.CreateTitle(p.sections[0]) case kind404: p.title = "404 Page not found" @@ -775,8 +764,7 @@ func (m *pageMeta) outputFormats() output.Formats { if len(m.configuredOutputFormats) > 0 { return m.configuredOutputFormats } - - return m.s.outputFormats[m.Kind()] + return m.s.conf.C.KindOutputFormats[m.Kind()] } func (p *pageMeta) Slug() string { |