mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
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 commitb6673e5309
. Revert "Add First Class Author Support" This reverts commitcf978c0649
.
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user