From 0882a21997b0830f43643cac9f0de4beaa698988 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 29 Sep 2024 15:54:01 +0200 Subject: Rework author configuration --- layouts/partials/author.html | 14 ------------- layouts/partials/head.html | 7 ++++++- layouts/partials/head/author.html | 13 ++++++++++++ layouts/partials/post-meta/author.html | 3 --- layouts/partials/schema.org/article.html | 19 ++++++++++++++--- layouts/partials/site-author.html | 35 -------------------------------- 6 files changed, 35 insertions(+), 56 deletions(-) delete mode 100644 layouts/partials/author.html create mode 100644 layouts/partials/head/author.html delete mode 100644 layouts/partials/post-meta/author.html delete mode 100644 layouts/partials/site-author.html (limited to 'layouts/partials') 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 @@ - + {{ $showAuthor := .Site.Params.showAuthor | default false }} + {{- $author := partial "head/author.html" . }} + {{ if (and $showAuthor (ne $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 }} - {{ i18n "by" . }} -{{ 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 }}