mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-24 21:56:05 +02:00
Added AuthorList, Author, AuthorSocial, SiteSocial, Image and Video structs
Added Page.Author(s) functions Added schema, opengraph, twitter_cards, google_news metadata templates Added "" template
This commit is contained in:
@@ -40,7 +40,8 @@ type Page struct {
|
||||
Summary template.HTML
|
||||
Aliases []string
|
||||
Status string
|
||||
Images []string
|
||||
Images []Image
|
||||
Videos []Video
|
||||
TableOfContents template.HTML
|
||||
Truncated bool
|
||||
Draft bool
|
||||
@@ -68,7 +69,6 @@ type Source struct {
|
||||
Content []byte
|
||||
source.File
|
||||
}
|
||||
|
||||
type PageMeta struct {
|
||||
WordCount int
|
||||
FuzzyWordCount int
|
||||
@@ -98,6 +98,32 @@ func (p *Page) IsPage() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *Page) Author() Author {
|
||||
authors := p.Authors()
|
||||
|
||||
for _, author := range authors {
|
||||
return author
|
||||
}
|
||||
return Author{}
|
||||
}
|
||||
|
||||
func (p *Page) Authors() AuthorList {
|
||||
authorKeys, ok := p.Params["authors"]
|
||||
authors := authorKeys.([]string)
|
||||
if !ok || 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
|
||||
}
|
||||
}
|
||||
return al
|
||||
}
|
||||
|
||||
func (p *Page) UniqueId() string {
|
||||
return p.Source.UniqueId()
|
||||
}
|
||||
|
Reference in New Issue
Block a user