diff options
| author | Serghei Iakovlev <egrep@protonmail.ch> | 2024-09-29 15:54:01 +0200 |
|---|---|---|
| committer | Serghei Iakovlev <git@serghei.pl> | 2024-09-29 18:15:42 +0200 |
| commit | 0882a21997b0830f43643cac9f0de4beaa698988 (patch) | |
| tree | 581a1dea498805ef5b9259fbf095b5546d705a78 /layouts/_default | |
| parent | ec19cd59b5fc2ee4dc12b65647099c595984c075 (diff) | |
| download | gohugo-theme-ed-0882a21997b0830f43643cac9f0de4beaa698988.tar.gz | |
Rework author configuration
Diffstat (limited to 'layouts/_default')
| -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 |
4 files changed, 71 insertions, 14 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 }} |
