hugolib: Allow url in front matter for list type pages

This enables some potential foot-shooting, but is needed for some special URL requirements.

Fixes #4263
This commit is contained in:
Bjørn Erik Pedersen
2018-01-12 17:17:10 +01:00
parent 46db900dab
commit 8a409894bd
3 changed files with 49 additions and 46 deletions

View File

@@ -223,7 +223,6 @@ type Page struct {
Lastmod time.Time
Sitemap Sitemap
URLPath
permalink string
relPermalink string
@@ -1111,6 +1110,7 @@ func (p *Page) update(f interface{}) error {
return fmt.Errorf("Only relative URLs are supported, %v provided", url)
}
p.URLPath.URL = cast.ToString(v)
p.URLPath.frontMatterURL = p.URLPath.URL
p.Params[loki] = p.URLPath.URL
case "type":
p.contentType = cast.ToString(v)
@@ -1809,10 +1809,11 @@ func (p *Page) String() string {
}
type URLPath struct {
URL string
Permalink string
Slug string
Section string
URL string
frontMatterURL string
Permalink string
Slug string
Section string
}
// Scratch returns the writable context associated with this Page.
@@ -1991,7 +1992,9 @@ func (p *Page) setValuesForKind(s *Site) {
p.URLPath.URL = "/"
case KindPage:
default:
p.URLPath.URL = "/" + path.Join(p.sections...) + "/"
if p.URLPath.URL == "" {
p.URLPath.URL = "/" + path.Join(p.sections...) + "/"
}
}
}