diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-09-18 19:10:11 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-09-18 19:16:39 +0200 |
commit | 4a79fa0c33f364cd753c022e0f741403985699b2 (patch) | |
tree | 1b0219c7dc48dac830e84ccda991ec5041ecdc1c | |
parent | 83533a88810563f79a59043918e9c54ce65dcbe0 (diff) |
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 b6673e5309685ae162fdef2dc39c3ce4385c6005.
Revert "Add First Class Author Support"
This reverts commit cf978c06496d99e76b08418422dda5797d90fed6.
-rw-r--r-- | docs/content/extras/analytics.md | 2 | ||||
-rw-r--r-- | docs/content/extras/authors.md | 165 | ||||
-rw-r--r-- | docs/content/extras/builders.md | 2 | ||||
-rw-r--r-- | docs/content/templates/rss.md | 5 | ||||
-rw-r--r-- | docs/content/templates/variables.md | 43 | ||||
-rw-r--r-- | hugolib/author.go | 151 | ||||
-rw-r--r-- | hugolib/node.go | 19 | ||||
-rw-r--r-- | hugolib/page.go | 42 | ||||
-rw-r--r-- | hugolib/site.go | 9 | ||||
-rw-r--r-- | tpl/template_embedded.go | 7 |
10 files changed, 50 insertions, 395 deletions
diff --git a/docs/content/extras/analytics.md b/docs/content/extras/analytics.md index a7f940c2e..112671df5 100644 --- a/docs/content/extras/analytics.md +++ b/docs/content/extras/analytics.md @@ -4,7 +4,7 @@ linktitle: Analytics menu: main: parent: extras -next: /extras/authors +next: /extras/builders prev: /extras/aliases title: Analytics in Hugo weight: 15 diff --git a/docs/content/extras/authors.md b/docs/content/extras/authors.md deleted file mode 100644 index b3ad6c6ad..000000000 --- a/docs/content/extras/authors.md +++ /dev/null @@ -1,165 +0,0 @@ ---- -date: 2016-08-22T14:27:50+02:00 -lastmod: 2016-08-22 -menu: - main: - parent: extras -title: Authors -weight: 20 -next: /extras/builders -prev: /extras/analytics ---- - -For larger websites it's not unusual to have multiple publishing content creators. Hugo tries to provide a standardized approach to organize relations between content and their authors. This can be achieved with author profiles. - -## Author profiles - -For each author you can create a profile that will contain metadata of him or her. Those profiles have to be saved under `data/_authors/`. The filename of the profile will later be used as an identifier. This way Hugo can associate content with one or multiple authors through their identifiers. An author's profile can be defined in the JSON, YAML or TOML format. - -### Profile example - -Let's suppose Alice Allison is a blogger. A simple unique identifier would be `alice`. Now, we have to create a file called `alice.toml` in the `data/_authors/` directory. The following example is the standardized template written in TOML: - -```toml -# file: data/_authors/alice.toml - -givenName = "Alice" # or firstName as alias -familyName = "Allison" # or lastName as alias -displayName = "Alice Allison" -thumbnail = "static/authors/alice-thumb.jpg" -image = "static/authors/alice-full.jpg" -shortBio = "My name is Alice and I'm a blogger." -bio = "My name is Alice and I'm a blogger... some other stuff" -email = "alice.allison@email.com" -weight = 10 - -[social] - facebook = "alice.allison" - twitter = "alice" - googleplus = "aliceallison1" - website = "www.example.com" - -[params] - random = "whatever you want" -``` - -All variables are optional but it's advised to fill all important ones (e.g. names and biography) because themes can vary in their usage. - -You can store files for the `thumbnail` and `image` attributes in the `static` folder. Then add the path to the photos relative to `static`, e.g. `/static/path/to/thumbnail.jpg`. - -Weight allows you to define the order of an author in the `.Authors` list, that can be accessed on nodes or via `.Site.Authors`. - -The `social` section contains all the links to the social network accounts of an author. Hugo is able to generate the account links for the most popular social networks automatically. This way, you only have to enter your username. You can find a list of all supported social networks [here](#linking-social-network-accounts-automatically). All other variables, like `website` in the example above remain untouched. - -The `params` section can contain arbitrary data much like the same-named section in the config file. What it contains is up to you. - -## Associating content through identifiers - -Earlier it was mentioned that content can be associated with an author through their corresponding identifer. In our case blogger Alice has the identifer `alice`. In the frontmatter of a content file you can create a list of identifiers and assign it to the `authors` variable. - -```yaml ---- -title: Why Hugo is so awesome -date: 2016-08-22T14:27:50+02:00 -authors: ["alice"] ---- - -Nothing to read here. Move along... -``` - -If multiple authors work on this blog post then append their identifiers to the `authors` list in the frontmatter as well. - -## Working with templates - -After a successful setup it's time to give some credit to the authors by showing them on the website. Within the templates Hugo provides a list of the author's profiles if they are listed in the `authors` variable within the frontmatter. - -The list is accessible via the `.Authors` template variable. Printing all authors of a the blog post is straight forward: - -``` -{{ range .Authors }} - {{ .DisplayName }} -{{ end }} - -# output: Alice Allison -``` - -Even if there are co-authors you may only want to show the main author. For this case you can use the `.Author` template variable **(note the singular form)**. The template variable contains the profile of the author that is first listed with his identifier in the frontmatter. - -> **Note:** you can find a list of all template variables to access the profile information [here]({{< relref "templates/variables.md#author-variables" >}}) - -### Linking social network accounts automatically - -As aforementioned, Hugo is able to generate links to profiles of the most popular social networks. The following social networks with their corrersponding identifiers are supported: `github`, `facebook`, `twitter`, `googleplus`, `pinterest`, `instagram`, `youtube` and `linkedin`. - -This is can be done with the `.Social.URL` function. Its only parameter is the name of the social network as they are defined in the profile (e.g. `facebook`, `googleplus`). Custom variables like `website` remain as they are. - -Most articles feature a small section with information about the author at the end. Let's create one containing the author's name, a thumbnail, a (summarized) biography and links to all social networks: - -```html -{{ with .Author }} - <h3>{{ .DisplayName }}</h3> - <img src="{{ .Thumbnail | absURL }}" alt="{{ .DisplayName }}"> - <p>{{ .ShortBio }}</p> - - <ul> - {{ range $network, $username := .Social }} - <li><a href="{{ $.Author.Social.URL $network }}">{{ $network }}</a></li> - {{ end }} - </ul> -{{ end }} -``` - -## Who published what? - -That question can be answered with a list of all authors and another list containing all articles that they each have written. Now we have to translate this idea into templates. The [taxonomy]({{< relref "taxonomies/overview.md" >}}) feature allows us to logically group content based on an information that they have in common, e.g. a tag or a category. Well, many articles share the same author, so this should sound familiar, right? - -In order to let Hugo know that we want to group content based on their author, we have to create a new taxonomy called `author` (the name corresponds to the variable in the frontmatter). Open your config file and add the following information: - -```toml -# file: config.toml - -[taxonomies] - author = "authors" -``` - -### Listing all authors - -In the next step we can create a template to list all authors of your website. Later, the list can be accessed at `www.example.com/authors/`. Create a new template in the `layouts/taxonomy/` directory called `authors.term.html`. This template will be exclusively used for this taxonomy. - -```html -<!-- file: layouts/taxonomy/author.term.html --> - -<ul> -{{ range $author, $v := .Data.Terms }} - {{ $profile := $.Authors.Get $author }} - <li> - <a href="{{ printf "%s/%s/" $.Data.Plural $author | absURL }}"> - {{ $profile.DisplayName }} - {{ $profile.ShortBio }} - </a> - </li> -{{ end }} -</ul> -``` - -`.Data.Terms` contains the identifiers of all authors and we can range over it to create a list with all author names. The `$profile` variable gives us access to the profile of the current author. This allows you to generate a nice info box with a thumbnail, a biography and social media links, like at the [end of a blog post](#linking-social-network-accounts-automatically). - -### Listing each author's publications - -Last but not least we have to create the second list that contains all publications of an author. Each list will be shown in its own page and can be accessed at `www.example.com/authors/<IDENTIFIER>`. Replace `<IDENTIFIER>` with a valid author identifier like `alice`. - -The layout for this page can be defined in the template `layouts/taxonomy/author.html`. - -```html -<!-- file: layouts/taxonomy/author.html --> - -{{ range .Data.Pages }} - <h2><a href="{{ .Permalink }}">{{ .Title }}</a></h2> - <span>written by {{ .Author.DisplayName }}</span> - - {{ .Summary }} -{{ end }} -``` - -The example above generates a simple list of all posts written by a single author. Inside the loop you've access to the complete set of [page variables]({{< relref "templates/variables.md#page-variables" >}}). Therefore, you can add additional information about the current posts like the publishing date or the tags. - -With a lot of content this list can quickly become very long. Consider to use the [pagination]({{< relref "extras/pagination.md" >}}) feature. It splits the list into smaller chunks and spreads them over multiple pages. diff --git a/docs/content/extras/builders.md b/docs/content/extras/builders.md index cdb17dfd4..1e5fcabb7 100644 --- a/docs/content/extras/builders.md +++ b/docs/content/extras/builders.md @@ -6,7 +6,7 @@ menu: main: parent: extras next: /extras/comments -prev: /extras/authors +prev: /extras/analytics title: Hugo Builders weight: 20 --- diff --git a/docs/content/templates/rss.md b/docs/content/templates/rss.md index 60e09ccf1..70c3c7704 100644 --- a/docs/content/templates/rss.md +++ b/docs/content/templates/rss.md @@ -69,7 +69,9 @@ This is the default RSS template that ships with Hugo. It adheres to the [RSS 2. <link>{{ .Permalink }}</link> <description>Recent content {{ with .Title }}in {{.}} {{ end }}on {{ .Site.Title }}</description> <generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }} - <language>{{.}}</language>{{end}}{{ with .Site.Copyright }} + <language>{{.}}</language>{{end}}{{ with .Site.Author.email }} + <managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }} + <webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }} <copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }} <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }} <atom:link href="{{.URL}}" rel="self" type="application/rss+xml" /> @@ -78,6 +80,7 @@ This is the default RSS template that ships with Hugo. It adheres to the [RSS 2. <title>{{ .Title }}</title> <link>{{ .Permalink }}</link> <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> + {{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}} <guid>{{ .Permalink }}</guid> <description>{{ .Content | html }}</description> </item> diff --git a/docs/content/templates/variables.md b/docs/content/templates/variables.md index 35e3940ca..b85387b46 100644 --- a/docs/content/templates/variables.md +++ b/docs/content/templates/variables.md @@ -2,7 +2,7 @@ aliases: - /doc/variables/ - /layout/variables/ -lastmod: 2016-08-22 +lastmod: 2015-12-08 date: 2013-07-01 linktitle: Variables menu: @@ -61,8 +61,6 @@ matter, content or derived from file location. **.Translations** A list of translated versions of the current page. See [Multilingual]({{< relref "content/multilingual.md" >}}) for more info. Note that the `Translation` variable is also available on node, e.g. home page etc. <br> **.IsTranslated** Whether there are any translations to display.<br> **.Lang** Language taken from the language extension notation. <br> -**.Author** Returns the first listed author for a page<br> -**.Authors** (**note the plural form**) Returns all listed authors for a page in the order they are defined in the front matter.<br> ## Page Params @@ -126,12 +124,10 @@ includes taxonomies, lists and the homepage. **.Translations** A list of translated versions of the current node. All nodes (except the pager nodes) can have translated counter parts. See [Multilingual]({{< relref "content/multilingual.md" >}}) for more info. <br> **.IsTranslated** Whether there are any translations to display.<br> **.Lang** The language code of this node.<br> -**.Author** Returns the first defined author, sorted by their weight attribute.<br> -**.Authors** (**note the plural form**) Returns all defined authors, sorted by their weight attribute.<br> ### Taxonomy Terms Node Variables -[Taxonomy Terms](/templates/terms/) pages are of the type "node" and have the following **additional** variables. These are available in `layouts/_defaults/terms.html` for example. +[Taxonomy Terms](/templates/terms/) pages are of the type "node" and have the following additional variables. These are available in `layouts/_defaults/terms.html` for example. **.Data.Singular** The singular name of the taxonomy<br> **.Data.Plural** The plural name of the taxonomy<br> @@ -172,7 +168,7 @@ Also available is `.Site` which has the following: **.Site.Files** All of the source files of the site.<br> **.Site.Menus** All of the menus in the site.<br> **.Site.Title** A string representing the title of the site.<br> -**.Site.Authors** An ordered list (ordered by defined weight) of the authors as defined in the site configuration. Have a look at [acessible attributes](#author-variables).<br> +**.Site.Author** A map of the authors as defined in the site configuration.<br> **.Site.LanguageCode** A string representing the language as defined in the site configuration. This is mostly used to populate the RSS feeds with the right language code.<br> **.Site.DisqusShortname** A string representing the shortname of the Disqus shortcode as defined in the site configuration.<br> **.Site.GoogleAnalytics** A string representing your tracking code for Google Analytics as defined in the site configuration.<br> @@ -203,39 +199,6 @@ Available are the following attributes: **.File.Ext** or **.File.Extension** The file extension of the content file, e.g. `md`<br> **.File.Dir** Given the path `content/posts/dir1/dir2/`, the relative directory path of the content file will be returned, e.g. `posts/dir1/dir2/`<br> -## Author variables - -This variables are used for the author profiles feature. You can find a more in-depth explaination with examples [here]({{< relref "extras/authors.md" >}}). - -The `authors` frontmatter variable represents a list of author identifiers. Those identifiers are used to match their corresponding profiles. `.Author` contains the profile associated with the first identifiers in the list. - -**.Author.ID** The identifier of an author (a.k.a. the filename of his/her profile)<br> -**.Author.GivenName** or **.Author.FirstName** The author's first name, e.g. Charles<br> -**.Author.FamilyName** or **.Author.LastName** The author's last name, e.g. Dickens<br> -**.Author.DisplayName** The author's full name, e.g. Charles Dickens<br> -**.Author.Thumbnail** A link to a thumbnail of the author. Maybe the relative path to an image in the `static` folder<br> -**.Author.Image** A larger image of the author. Can be stored in the `static` folder as well.<br> -**.Author.Bio** A biography with background information about the author<br> -**.Author.ShortBio** A summarized version of the biography<br> -**.Author.Email** The email of the author<br> -**.Author.Weight** The associated weight of an author. Defines the order of authors in the `.Authors` list (except on pages due to the frontmatter)<br> -**.Author.Social** A container holding the values from the `social` section of the author's profile. For example, a TOML profile (excerpt) might look like this: - - [social] - facebook = "charles.dickens" - twitter = "charlesdickens" -**.Author.Params** A container holding the values from the `params` section of the author's file. The values can be arbitrary and depend on the profile. For example, a TOML profile (excerpt) might look like this: - - [params] - random = "whatever you want" -**.Author.Social.URL** Takes a social network as argument (as string) and generates the link the account automatically. A list of supported social networks and a template can be found [here]({{< relref "extras/authors.md#linking-social-network-accounts-automatically" >}}). - ---- - -`.Authors` (**note the plural form**) is a list of all author profiles that are mentioned in the `authors` frontmatter variable. - -**.Authors.Get** Takes the identifier of an author as argument (as string) and returns an `.Author` object. - ## Hugo Variables Also available is `.Hugo` which has the following: diff --git a/hugolib/author.go b/hugolib/author.go index 9aa71b5df..0f4327097 100644 --- a/hugolib/author.go +++ b/hugolib/author.go @@ -13,51 +13,23 @@ package hugolib -import ( - "fmt" - "regexp" - "sort" - "strings" - - "github.com/spf13/cast" -) - -var ( - onlyNumbersRegExp = regexp.MustCompile("^[0-9]*$") -) - -// Authors is a list of all authors and their metadata. -type Authors []Author - -// Get returns an author from an ID -func (a Authors) Get(id string) Author { - for _, author := range a { - if author.ID == id { - return author - } - } - return Author{} -} +// AuthorList is a list of all authors and their metadata. +type AuthorList map[string]Author // Author contains details about the author of a page. type Author struct { - ID string - GivenName string // givenName OR firstName - FirstName string // alias for GivenName - FamilyName string // familyName OR lastName - LastName string // alias for FamilyName - DisplayName string // displayName - Thumbnail string // thumbnail - Image string // image - ShortBio string // shortBio - Bio string // bio - Email string // email - Social AuthorSocial // social - Params map[string]string // params - Weight int + GivenName string + FamilyName string + DisplayName string + Thumbnail string + Image string + ShortBio string + LongBio string + Email string + Social AuthorSocial } -// AuthorSocial is a place to put social usernames per author. These are the +// AuthorSocial is a place to put social details per author. These are the // standard keys that themes will expect to have available, but can be // expanded to any others on a per site basis // - website @@ -71,102 +43,3 @@ type Author struct { // - linkedin // - skype type AuthorSocial map[string]string - -// URL is a convenience function that provides the correct canonical URL -// for a specific social network given a username. If an unsupported network -// is requested, only the username is returned -func (as AuthorSocial) URL(key string) string { - switch key { - case "github": - return fmt.Sprintf("https://github.com/%s", as[key]) - case "facebook": - return fmt.Sprintf("https://www.facebook.com/%s", as[key]) - case "twitter": - return fmt.Sprintf("https://twitter.com/%s", as[key]) - case "googleplus": - isNumeric := onlyNumbersRegExp.Match([]byte(as[key])) - if isNumeric { - return fmt.Sprintf("https://plus.google.com/%s", as[key]) - } - return fmt.Sprintf("https://plus.google.com/+%s", as[key]) - case "pinterest": - return fmt.Sprintf("https://www.pinterest.com/%s/", as[key]) - case "instagram": - return fmt.Sprintf("https://www.instagram.com/%s/", as[key]) - case "youtube": - return fmt.Sprintf("https://www.youtube.com/user/%s", as[key]) - case "linkedin": - return fmt.Sprintf("https://www.linkedin.com/in/%s", as[key]) - default: - return as[key] - } -} - -func mapToAuthors(m map[string]interface{}) Authors { - authors := make(Authors, len(m)) - for authorID, data := range m { - authorMap, ok := data.(map[string]interface{}) - if !ok { - continue - } - authors = append(authors, mapToAuthor(authorID, authorMap)) - } - sort.Stable(authors) - return authors -} - -func mapToAuthor(id string, m map[string]interface{}) Author { - author := Author{ID: id} - for k, data := range m { - switch k { - case "givenName", "firstName": - author.GivenName = cast.ToString(data) - author.FirstName = author.GivenName - case "familyName", "lastName": - author.FamilyName = cast.ToString(data) - author.LastName = author.FamilyName - case "displayName": - author.DisplayName = cast.ToString(data) - case "thumbnail": - author.Thumbnail = cast.ToString(data) - case "image": - author.Image = cast.ToString(data) - case "shortBio": - author.ShortBio = cast.ToString(data) - case "bio": - author.Bio = cast.ToString(data) - case "email": - author.Email = cast.ToString(data) - case "social": - author.Social = normalizeSocial(cast.ToStringMapString(data)) - case "params": - author.Params = cast.ToStringMapString(data) - } - } - - // set a reasonable default for DisplayName - if author.DisplayName == "" { - author.DisplayName = author.GivenName + " " + author.FamilyName - } - - return author -} - -// normalizeSocial makes a naive attempt to normalize social media usernames -// and strips out extraneous characters or url info -func normalizeSocial(m map[string]string) map[string]string { - for network, username := range m { - username = strings.TrimSpace(username) - username = strings.TrimSuffix(username, "/") - strs := strings.Split(username, "/") - username = strs[len(strs)-1] - username = strings.TrimPrefix(username, "@") - username = strings.TrimPrefix(username, "+") - m[network] = username - } - return m -} - -func (a Authors) Len() int { return len(a) } -func (a Authors) Swap(i, j int) { a[i], a[j] = a[j], a[i] } -func (a Authors) Less(i, j int) bool { return a[i].Weight < a[j].Weight } diff --git a/hugolib/node.go b/hugolib/node.go index 820c483a6..566fd4799 100644 --- a/hugolib/node.go +++ b/hugolib/node.go @@ -21,9 +21,11 @@ import ( "sync" "time" - "github.com/spf13/cast" - "github.com/spf13/hugo/helpers" jww "github.com/spf13/jwalterweatherman" + + "github.com/spf13/hugo/helpers" + + "github.com/spf13/cast" ) type Node struct { @@ -320,16 +322,3 @@ func (n *Node) addLangFilepathPrefix(outfile string) string { } return helpers.FilePathSeparator + filepath.Join(n.Lang(), outfile) } - -// Author returns the first defined author, sorted by Weight -func (n *Node) Author() Author { - if len(n.Site.Authors) == 0 { - return Author{} - } - return n.Site.Authors[0] -} - -// Authors returns all defined authors, sorted by Weight -func (n *Node) Authors() Authors { - return n.Site.Authors -} diff --git a/hugolib/page.go b/hugolib/page.go index 1d826f51e..b72cfcfe9 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -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{} } - - authorIDs, ok := p.Params["authors"].([]string) - if !ok || len(authorIDs) == 0 || len(p.Site.Authors) == 0 { - return Authors{} + authors := authorKeys.([]string) + if len(authors) < 1 || len(p.Site.Authors) < 1 { + return AuthorList{} } - authors := make([]Author, 0, len(authorIDs)) - for _, authorID := range authorIDs { - a := p.Site.Authors.Get(authorID) - if a.ID == authorID { - authors = append(authors, a) + al := make(AuthorList) + for _, author := range authors { + a, ok := p.Site.Authors[author] + if ok { + al[author] = a } } - - return authors + return al } func (p *Page) UniqueID() string { diff --git a/hugolib/site.go b/hugolib/site.go index f7872ba99..87c440d38 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -165,7 +165,7 @@ type SiteInfo struct { BaseURL template.URL Taxonomies TaxonomyList - Authors Authors + Authors AuthorList Social SiteSocial Sections Taxonomy Pages *Pages // Includes only pages in this language @@ -176,6 +176,7 @@ type SiteInfo struct { Hugo *HugoInfo Title string RSSLink string + Author map[string]interface{} LanguageCode string DisqusShortname string GoogleAnalytics string @@ -732,11 +733,6 @@ func (s *Site) readDataFromSourceFS() error { } err = s.loadData(dataSources) - - // extract author data from /data/_authors then delete it from .Data - s.Info.Authors = mapToAuthors(cast.ToStringMap(s.Data["_authors"])) - delete(s.Data, "_authors") - s.timerStep("load data") return err } @@ -912,6 +908,7 @@ func (s *Site) initializeSiteInfo() { s.Info = SiteInfo{ BaseURL: template.URL(helpers.SanitizeURLKeepTrailingSlash(viper.GetString("BaseURL"))), Title: lang.GetString("Title"), + Author: lang.GetStringMap("author"), Social: lang.GetStringMapString("social"), LanguageCode: lang.GetString("languagecode"), Copyright: lang.GetString("copyright"), diff --git a/tpl/template_embedded.go b/tpl/template_embedded.go index 185f7aecd..c418511ac 100644 --- a/tpl/template_embedded.go +++ b/tpl/template_embedded.go @@ -44,7 +44,7 @@ func (t *GoHTMLTemplate) EmbedShortcodes() { t.AddInternalShortcode("speakerdeck.html", "<script async class='speakerdeck-embed' data-id='{{ index .Params 0 }}' data-ratio='1.33333333333333' src='//speakerdeck.com/assets/embed.js'></script>") t.AddInternalShortcode("youtube.html", `{{ if .IsNamedParams }} <div {{ if .Get "class" }}class="{{ .Get "class" }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}> - <iframe src="//www.youtube.com/embed/{{ .Get "id" }}?{{ with .Get "autoplay" }}{{ if eq . "true" }}autoplay=1{{ end }}{{ end }}" + <iframe src="//www.youtube.com/embed/{{ .Get "id" }}?{{ with .Get "autoplay" }}{{ if eq . "true" }}autoplay=1{{ end }}{{ end }}" {{ if not (.Get "class") }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" {{ end }}allowfullscreen frameborder="0"></iframe> </div>{{ else }} <div {{ if len .Params | eq 2 }}class="{{ .Get 1 }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}> @@ -70,7 +70,9 @@ func (t *GoHTMLTemplate) EmbedTemplates() { <link>{{ .Permalink }}</link> <description>Recent content {{ with .Title }}in {{.}} {{ end }}on {{ .Site.Title }}</description> <generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }} - <language>{{.}}</language>{{end}}{{ with .Site.Copyright }} + <language>{{.}}</language>{{end}}{{ with .Site.Author.email }} + <managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }} + <webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }} <copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }} <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }} <atom:link href="{{.Permalink}}" rel="self" type="application/rss+xml" /> @@ -79,6 +81,7 @@ func (t *GoHTMLTemplate) EmbedTemplates() { <title>{{ .Title }}</title> <link>{{ .Permalink }}</link> <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> + {{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}} <guid>{{ .Permalink }}</guid> <description>{{ .Content | html }}</description> </item> |