diff options
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/_default/home.humanstxt.txt | 12 | ||||
| -rw-r--r-- | layouts/_default/list.atom.xml | 5 | ||||
| -rw-r--r-- | layouts/_default/list.feed.xml | 3 | ||||
| -rw-r--r-- | layouts/_default/list.jsonfeed.json | 6 | ||||
| -rw-r--r-- | layouts/partials/author.html | 6 | ||||
| -rw-r--r-- | layouts/partials/schema.org/article.html | 6 | ||||
| -rw-r--r-- | layouts/partials/site-author.html | 34 |
7 files changed, 58 insertions, 14 deletions
diff --git a/layouts/_default/home.humanstxt.txt b/layouts/_default/home.humanstxt.txt index 0d3efe9..23286fe 100644 --- a/layouts/_default/home.humanstxt.txt +++ b/layouts/_default/home.humanstxt.txt @@ -1,11 +1,12 @@ -{{- with site.Author.name }} +{{- $siteAuthor := partial "site-author.html" . -}} +{{- with $siteAuthor.name }} /* TEAM */ Author: {{ . }} -{{- with site.Author.email }}{{ printf "\n Contact: %s" . }}{{ end }} -{{- with site.Author.github }}{{ printf "\n GitHub: @%s" . }}{{ end }} -{{- with site.Author.twitter }}{{ printf "\n Twitter: @%s" . }}{{ end }} -{{- with site.Author.location }}{{ printf "\n From: %s" . }}{{ end }} +{{- 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 }} {{- end }} /* SITE */ @@ -15,3 +16,4 @@ Doctype: HTML5 Standards: HTML5, CSS3, Open Graph protocol, Schema.org Components: Hugo, Ed Theme, Lunr.js + Hugo version: {{ site.Hugo.Version }} diff --git a/layouts/_default/list.atom.xml b/layouts/_default/list.atom.xml index 67ff79b..edc133b 100644 --- a/layouts/_default/list.atom.xml +++ b/layouts/_default/list.atom.xml @@ -15,6 +15,7 @@ {{- $pages = $pages | first $limit -}} {{- $siteLastMod := partial "site-last-mod.html" . -}} +{{- $siteAuthor := partial "site-author.html" . -}} {{- 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 }}"> @@ -28,10 +29,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 site.Author.name }} + <logo>{{ $logo.Permalink | absURL }}</logo>{{ with $siteAuthor.name }} <author> {{ printf `<name type="html"><![CDATA[%s]]></name>` . | safeHTML }} - {{ with site.Author.email }}<email>{{ . | html }}</email>{{ end }} + {{ with $siteAuthor.email }}<email>{{ . | html }}</email>{{ end }} </author>{{ end }}{{ with site.Params.Copyright }}{{ $copyright := replace . "{year}" now.Year }}{{ $copyright = replace $copyright "©" "©" }} <rights>{{ $copyright | plainify }}</rights>{{ end }} <generator uri="https://gohugo.io" version="{{ hugo.Version }}">Hugo</generator>{{ if ne $siteLastMod "" }} diff --git a/layouts/_default/list.feed.xml b/layouts/_default/list.feed.xml index 2bc3cb7..ae4366b 100644 --- a/layouts/_default/list.feed.xml +++ b/layouts/_default/list.feed.xml @@ -15,6 +15,7 @@ {{- $pages = $pages | first $limit -}} {{- $siteLastMod := partial "site-last-mod.html" . -}} +{{- $siteAuthor := partial "site-author.html" . -}} {{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }} <rss version="2.0" @@ -47,7 +48,7 @@ {{- end -}} {{- end }} {{ with site.Params.description }}{{ printf `<description type="html"><![CDATA[%s]]></description>` . | safeHTML }}{{ end }} - <generator>Hugo {{ hugo.Version }}</generator>{{ with site.Author.name }} + <generator>Hugo {{ hugo.Version }}</generator>{{ with $siteAuthor.name }} {{ printf `<dc:creator type="html"><![CDATA[%s]]></dc:creator>` . | safeHTML }}{{ end }}{{ with site.LanguageCode }} <language>{{ . }}</language>{{ end }}{{ with site.Params.Copyright }}{{ $copyright := replace . "{year}" now.Year }}{{ $copyright = replace $copyright "©" "©" }} <copyright>{{ $copyright | plainify }}</copyright>{{ end }}{{ if ne $siteLastMod "" }} diff --git a/layouts/_default/list.jsonfeed.json b/layouts/_default/list.jsonfeed.json index f6b89cc..29c9bf4 100644 --- a/layouts/_default/list.jsonfeed.json +++ b/layouts/_default/list.jsonfeed.json @@ -14,6 +14,8 @@ {{- $limit := site.Params.feedSize | default 25 -}} {{- $pages = $pages | first $limit -}} +{{- $siteAuthor := partial "site-author.html" . -}} + { "version": "https://jsonfeed.org/version/1.1", "title": {{ (partial "title.html" .) | htmlUnescape | jsonify }}, @@ -23,9 +25,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 site.Author.name }}"authors": [ + {{ with $siteAuthor.name }}"authors": [ { - "name": {{ . | jsonify }}{{ with site.Author.twitter }}, + "name": {{ . | jsonify }}{{ with $siteAuthor.twitter }}, "url": {{ (printf "https://twitter.com/%s" . ) | jsonify }}{{ end }} } ],{{ end }} diff --git a/layouts/partials/author.html b/layouts/partials/author.html index 2bfddb3..4ca1209 100644 --- a/layouts/partials/author.html +++ b/layouts/partials/author.html @@ -1,3 +1,5 @@ +{{- $siteAuthor := partial "site-author.html" . -}} + {{- /* First, check for current page author(s) */}} {{- if .Params.author }} {{- $author_type := (printf "%T" .Params.author) }} @@ -7,6 +9,6 @@ {{- .Params.author }} {{- end }} {{- /* Otherwise, get site authors */}} -{{- else if site.Author.name }} - {{- site.Author.name }} +{{- else if $siteAuthor.name }} + {{- $siteAuthor.name }} {{- end -}} diff --git a/layouts/partials/schema.org/article.html b/layouts/partials/schema.org/article.html index fcec66b..f4112b6 100644 --- a/layouts/partials/schema.org/article.html +++ b/layouts/partials/schema.org/article.html @@ -13,6 +13,8 @@ {{- $logo := resources.Get (site.Params.assets.logo | default "/img/open-graph-logo.png") -}} {{- $logo = $logo.Resize "96x96" }} +{{- $siteAuthor := partial "site-author.html" . }} + <script type="application/ld+json" id="schema-data"> { "@context": "https://schema.org", @@ -51,10 +53,10 @@ ], {{- end }} {{- else }} - {{- with site.Author.name }} + {{- with $siteAuthor.name }} "author": { "@type": "Person", - "name": {{ . }}{{ with site.Author.twitter }}, + "name": {{ . }}{{ with $siteAuthor.twitter }}, "url": "https://twitter.com/{{ . }}"{{ end }} }, {{- end }} diff --git a/layouts/partials/site-author.html b/layouts/partials/site-author.html new file mode 100644 index 0000000..1ddd06c --- /dev/null +++ b/layouts/partials/site-author.html @@ -0,0 +1,34 @@ +{{- /* + +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 -}} +{{- end -}} + +{{- return $siteAuthor -}} |
