hubolib: Revert to .Type = "page" when empty

This was changed with good intentions in 0.63.0.

This behaviour was not documented, but it was of course in use.

This commit rolls back to how it behaved before:

For `Page.Type` you will get:

* `type` from front matter if set.
* `.Section`
* If none of the above returns anything, return "page"

Fixes #6805
This commit is contained in:
Bjørn Erik Pedersen
2020-01-26 15:53:42 +01:00
parent 74b6c4e5ff
commit e8831a056b
3 changed files with 24 additions and 4 deletions

View File

@@ -291,12 +291,18 @@ func (p *pageMeta) Title() string {
return p.title
}
const defaultContentType = "page"
func (p *pageMeta) Type() string {
if p.contentType != "" {
return p.contentType
}
return p.Section()
if sect := p.Section(); sect != "" {
return sect
}
return defaultContentType
}
func (p *pageMeta) Weight() int {