Revert the "standardize author data"

There were some breaking changes etc. that is too late to fix for 0.17.

Let us think this through and add proper author support for Hugo 0.18.

Fixes #2464

Revert "docs: Add documentation for author profiles"

This reverts commit b6673e5309.

Revert "Add First Class Author Support"

This reverts commit cf978c0649.
This commit is contained in:
Bjørn Erik Pedersen
2016-09-18 19:10:11 +02:00
parent 83533a8881
commit 4a79fa0c33
10 changed files with 53 additions and 398 deletions

View File

@@ -190,41 +190,33 @@ func (p *Page) Param(key interface{}) (interface{}, error) {
return p.Site.Params[keyStr], nil
}
// Author returns the first listed author for a page
func (p *Page) Author() Author {
authors := p.Authors()
if len(authors) == 0 {
return Author{}
for _, author := range authors {
return author
}
return authors[0]
return Author{}
}
// Authors returns all listed authors for a page in the order they
// are defined in the front matter. It first checks for a single author
// since that it the most common use case, then checks for multiple authors.
func (p *Page) Authors() Authors {
authorID, ok := p.Params["author"].(string)
if ok {
a := p.Site.Authors.Get(authorID)
if a.ID == authorID {
return Authors{a}
func (p *Page) Authors() AuthorList {
authorKeys, ok := p.Params["authors"]
if !ok {
return AuthorList{}
}
authors := authorKeys.([]string)
if len(authors) < 1 || len(p.Site.Authors) < 1 {
return AuthorList{}
}
al := make(AuthorList)
for _, author := range authors {
a, ok := p.Site.Authors[author]
if ok {
al[author] = a
}
}
authorIDs, ok := p.Params["authors"].([]string)
if !ok || len(authorIDs) == 0 || len(p.Site.Authors) == 0 {
return Authors{}
}
authors := make([]Author, 0, len(authorIDs))
for _, authorID := range authorIDs {
a := p.Site.Authors.Get(authorID)
if a.ID == authorID {
authors = append(authors, a)
}
}
return authors
return al
}
func (p *Page) UniqueID() string {