diff options
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/_default/home.humanstxt.txt | 38 | ||||
| -rw-r--r-- | layouts/_default/list.atom.xml | 22 | ||||
| -rw-r--r-- | layouts/_default/list.jsonfeed.json | 19 | ||||
| -rw-r--r-- | layouts/_default/single.html | 6 | ||||
| -rw-r--r-- | layouts/partials/author.html | 14 | ||||
| -rw-r--r-- | layouts/partials/head.html | 7 | ||||
| -rw-r--r-- | layouts/partials/head/author.html | 13 | ||||
| -rw-r--r-- | layouts/partials/post-meta/author.html | 3 | ||||
| -rw-r--r-- | layouts/partials/schema.org/article.html | 19 | ||||
| -rw-r--r-- | layouts/partials/site-author.html | 35 |
10 files changed, 106 insertions, 70 deletions
diff --git a/layouts/_default/home.humanstxt.txt b/layouts/_default/home.humanstxt.txt index 23286fe..98b1c79 100644 --- a/layouts/_default/home.humanstxt.txt +++ b/layouts/_default/home.humanstxt.txt @@ -1,12 +1,38 @@ -{{- $siteAuthor := partial "site-author.html" . -}} -{{- with $siteAuthor.name }} +{{- $authorName := "" }} +{{- $authorEmail := "" }} +{{- $authorGithub := "" }} +{{- $authorTwitter := "" }} +{{- $authorLocation := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .email }} + {{- $authorEmail = . }} + {{- end -}} + {{- with .name }} + {{- $authorName = . }} + {{- end }} + {{- with .github }} + {{- $authorGithub = . }} + {{- end }} + {{- with .twitter }} + {{- $authorTwitter = . }} + {{- end }} + {{- with .location }} + {{- $authorLocation = . }} + {{- end }} + {{- else }} + {{- $authorName = . }} + {{- end }} +{{- end }} + +{{- with $authorName }} /* TEAM */ Author: {{ . }} -{{- with $siteAuthor.email }}{{ printf "\n Contact: %s" . }}{{ end }} -{{- with $siteAuthor.github }}{{ printf "\n GitHub: @%s" . }}{{ end }} -{{- with $siteAuthor.twitter }}{{ printf "\n Twitter: @%s" . }}{{ end }} -{{- with $siteAuthor.location }}{{ printf "\n From: %s" . }}{{ end }} +{{- with $authorEmail }}{{ printf "\n Contact: %s" . }}{{ end }} +{{- with $authorGithub }}{{ printf "\n GitHub: @%s" . }}{{ end }} +{{- with $authorTwitter }}{{ printf "\n Twitter: @%s" . }}{{ end }} +{{- with $authorLocation }}{{ printf "\n From: %s" . }}{{ end }} {{- end }} /* SITE */ diff --git a/layouts/_default/list.atom.xml b/layouts/_default/list.atom.xml index 6ef45ab..c51bebd 100644 --- a/layouts/_default/list.atom.xml +++ b/layouts/_default/list.atom.xml @@ -15,7 +15,21 @@ {{- $pages = $pages | first $limit -}} {{- $siteLastMod := partial "site-last-mod.html" . -}} -{{- $siteAuthor := partial "site-author.html" . -}} + +{{- $authorEmail := "" }} +{{- $authorName := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .email }} + {{- $authorEmail = . }} + {{- end -}} + {{- with .name }} + {{- $authorName = . }} + {{- end }} + {{- else }} + {{- $authorName = . }} + {{- end }} +{{- end }} {{- safeHTML "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" }} <feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xml:lang="{{ site.LanguageCode }}" xml:base="{{ site.BaseURL }}"> @@ -29,10 +43,10 @@ {{- end -}} {{- end }} {{ $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png") }}{{ $logo = $logo.Resize "96x96" }}<icon>{{ $logo.Permalink | absURL }}</icon> - <logo>{{ $logo.Permalink | absURL }}</logo>{{ with $siteAuthor.name }} + <logo>{{ $logo.Permalink | absURL }}</logo>{{ if or (not (eq $authorEmail "")) (not (eq $authorName "")) }} <author> - <name>{{ . }}</name> - {{ with $siteAuthor.email }}<email>{{ . | html }}</email>{{ end }} + {{ with $authorName }}<name>{{ . }}</name>{{ end }} + {{ with $authorEmail }}<email>{{ . | html }}</email>{{ end }} </author>{{ end }}{{ with site.Params.Copyright }} <rights>{{ . | plainify }}</rights>{{ end }} <generator uri="https://gohugo.io" version="{{ hugo.Version }}">Hugo</generator>{{ if ne $siteLastMod "" }} diff --git a/layouts/_default/list.jsonfeed.json b/layouts/_default/list.jsonfeed.json index 29c9bf4..d44c7e0 100644 --- a/layouts/_default/list.jsonfeed.json +++ b/layouts/_default/list.jsonfeed.json @@ -14,7 +14,20 @@ {{- $limit := site.Params.feedSize | default 25 -}} {{- $pages = $pages | first $limit -}} -{{- $siteAuthor := partial "site-author.html" . -}} +{{- $authorName := "" }} +{{- $authorTwitter := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .name }} + {{- $authorName = . }} + {{- end -}} + {{- with .twitter }} + {{- $authorTwitter = . }} + {{- end }} + {{- else }} + {{- $authorName = . }} + {{- end }} +{{- end }} { "version": "https://jsonfeed.org/version/1.1", @@ -25,9 +38,9 @@ {{- $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png") }}{{ $logo = $logo.Resize "96x96" }} "icon": {{ $logo.Permalink | jsonify }}, "favicon": {{ $logo.Permalink | jsonify }}, - {{ with $siteAuthor.name }}"authors": [ + {{ with $authorName }}"authors": [ { - "name": {{ . | jsonify }}{{ with $siteAuthor.twitter }}, + "name": {{ . | jsonify }}{{ with $authorTwitter }}, "url": {{ (printf "https://twitter.com/%s" . ) | jsonify }}{{ end }} } ],{{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index fe33269..a061e89 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -7,7 +7,11 @@ </h1> <p class="byline"> {{ if in (slice "drama" "narrative" "poem") $postType }} - {{ partial "post-meta/author.html" . }} + {{ $showAuthor := .Site.Params.showAuthor | default false }} + {{ $author := partial "head/author.html" . }} + {{ if (and $showAuthor (ne $author ""))}} + <span class="author">{{ i18n "by" . }}</span> + {{ end }} {{ else }} {{ partial "post-meta/date.html" . }} {{ end }} diff --git a/layouts/partials/author.html b/layouts/partials/author.html deleted file mode 100644 index 4ca1209..0000000 --- a/layouts/partials/author.html +++ /dev/null @@ -1,14 +0,0 @@ -{{- $siteAuthor := partial "site-author.html" . -}} - -{{- /* First, check for current page author(s) */}} -{{- if .Params.author }} - {{- $author_type := (printf "%T" .Params.author) }} - {{- if (or (eq $author_type "[]string") (eq $author_type "[]interface {}")) }} - {{- (delimit .Params.author ", " ) }} - {{- else }} - {{- .Params.author }} - {{- end }} -{{- /* Otherwise, get site authors */}} -{{- else if $siteAuthor.name }} - {{- $siteAuthor.name }} -{{- end -}} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 94684a2..0a4b02a 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -8,7 +8,12 @@ <meta name="description" content="{{ partial "description.html" . }}"> <meta name="keywords" content="{{ delimit (partial "keywords.html" .) ", " }}"> - <meta name="author" content="{{ partial "author.html" . }}"> + {{ $showAuthor := .Site.Params.showAuthor | default false }} + {{- $author := partial "head/author.html" . }} + {{ if (and $showAuthor (ne $author ""))}} + <meta name="author" content="{{ $author }}"> + {{- end }} + {{ hugo.Generator }} {{ partial "styles.html" . }} diff --git a/layouts/partials/head/author.html b/layouts/partials/head/author.html new file mode 100644 index 0000000..94788e9 --- /dev/null +++ b/layouts/partials/head/author.html @@ -0,0 +1,13 @@ +{{- $author := "" -}} + +{{- with .Params.author -}} + {{- if (reflect.IsSlice .) -}} + {{- $author = delimit . ", " -}} + {{- else -}} + {{- $author = . -}} + {{- end -}} +{{- else -}} + {{- $author = site.Params.author.name -}} +{{- end -}} + +{{- return $author -}} diff --git a/layouts/partials/post-meta/author.html b/layouts/partials/post-meta/author.html deleted file mode 100644 index 1b56004..0000000 --- a/layouts/partials/post-meta/author.html +++ /dev/null @@ -1,3 +0,0 @@ -{{ with .Params.author }} - <span class="author">{{ i18n "by" . }}</span> -{{ end }} diff --git a/layouts/partials/schema.org/article.html b/layouts/partials/schema.org/article.html index f4112b6..1549784 100644 --- a/layouts/partials/schema.org/article.html +++ b/layouts/partials/schema.org/article.html @@ -13,7 +13,20 @@ {{- $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png") -}} {{- $logo = $logo.Resize "96x96" }} -{{- $siteAuthor := partial "site-author.html" . }} +{{- $siteAuthorName := "" }} +{{- $siteAuthorTwitter := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .name }} + {{- $siteAuthorName = . }} + {{- end -}} + {{- with .twitter }} + {{- $siteAuthorTwitter = . }} + {{- end }} + {{- else }} + {{- $siteAuthorName = . }} + {{- end }} +{{- end }} <script type="application/ld+json" id="schema-data"> { @@ -53,10 +66,10 @@ ], {{- end }} {{- else }} - {{- with $siteAuthor.name }} + {{- with $siteAuthorName }} "author": { "@type": "Person", - "name": {{ . }}{{ with $siteAuthor.twitter }}, + "name": {{ . }}{{ with $siteAuthorTwitter }}, "url": "https://twitter.com/{{ . }}"{{ end }} }, {{- end }} diff --git a/layouts/partials/site-author.html b/layouts/partials/site-author.html deleted file mode 100644 index cd6dbf4..0000000 --- a/layouts/partials/site-author.html +++ /dev/null @@ -1,35 +0,0 @@ -{{- /* - -This partial is used to get the site author information. - -In Hugo v0.124.0, the site.Author variable was deprecated. Instead, it is recommended to use -the "author" parameters in the site configuration file. - -This partial checks for the presence of author information in both site.Author and site.Params.author. -If both are present, preference is given to site.Params.author. - -The result is stored in the $siteAuthor variable and returned by the partial. - -Usage: - - {{ $siteAuthor := partial "site-author.html" . }} - - {{ with $siteAuthor.name }} {{ . }} {{ end }} - {{ with $siteAuthor.email }} {{ . }} {{ end }} - {{ with $siteAuthor.github }} {{ . }} {{ end }} - {{ with $siteAuthor.twitter }} {{ . }} {{ end }} - {{ with $siteAuthor.location }} {{ . }} {{ end }} - -For more information, see: https://github.com/gohugoio/hugo/releases/tag/v0.124.0 -*/ -}} - -{{- $siteAuthor := dict "name" "" "email" "" "github" "" "twitter" "" "location" "" -}} - -{{- if site.Params.author -}} - {{- $siteAuthor = merge $siteAuthor site.Params.author -}} -{{- else if site.Author -}} - {{- $siteAuthor = merge $siteAuthor site.Author -}} - {{- warnf "The author key in site configuration is deprecated. Use site.params.author instead." }} -{{- end -}} - -{{- return $siteAuthor -}} |
