From 91e6ea957510cc44524c8eebf3d28367d9d9ce1f Mon Sep 17 00:00:00 2001 From: Will Faught Date: Wed, 20 Sep 2023 23:00:59 -0700 Subject: [PATCH] Add email, url author attributes --- README.md | 10 +++++++--- exampleSite/hugo.toml | 4 +++- layouts/partials/paige/authors.html | 18 ++++++++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 71f43d8d..1ce0f5e1 100644 --- a/README.md +++ b/README.md @@ -291,8 +291,10 @@ Optional site parameters: ```toml [authors.will-faught] -name = "Will Faught" default = false # Credit this author in pages that have no authors parameter +email = "will.faught@example.com" +name = "Will Faught" +url = "https://willfaught.com/paige" ``` Optional page parameters: @@ -304,8 +306,10 @@ link = "https://youtu.be/dQw4w9WgXcQ" # The reference for an anchor around the t [[authors]] author = "will-faught" # Credit the corresponding author in the site parameters -[[authors]] -name = "Will Faught" # Credit this author +[[authors]] # Credit this author +email = "will.faught@example.com" +name = "Will Faught" +url = "https://willfaught.com/paige" [paige] alert = "Alert!" # Markdown displayed before the page body (defaults to primary alert type) diff --git a/exampleSite/hugo.toml b/exampleSite/hugo.toml index 3aa3d3d7..78d19c39 100644 --- a/exampleSite/hugo.toml +++ b/exampleSite/hugo.toml @@ -87,8 +87,10 @@ path = "github.com/willfaught/paige" home = ["html", "json", "rss"] [params.authors.will-faught] -name = "Will Faught" default = true +email = "will.faught@example.com" +name = "Will Faught" +url = "https://willfaught.com/paige" [params.paige.git] commit_url = "https://github.com/willfaught/paige/commit/%s" diff --git a/layouts/partials/paige/authors.html b/layouts/partials/paige/authors.html index 100f2f88..6202cd6d 100644 --- a/layouts/partials/paige/authors.html +++ b/layouts/partials/paige/authors.html @@ -4,27 +4,37 @@ {{ if $page.Params.authors }} {{ range $page.Params.authors }} + {{ $email := "" }} {{ $id := "" }} {{ $name := "" }} + {{ $url := "" }} {{ if reflect.IsMap . }} {{ with .author }} {{ $id = . }} - {{ $name = (index site.Params.authors .).name }} + {{ $author := index site.Params.authors $id }} + {{ $email = $author.email }} + {{ $name = $author.name }} + {{ $url = $author.url }} {{ else }} + {{ $email = .email }} {{ $name = .name }} + {{ $url = .url }} {{ end }} {{ else }} {{ $id = . }} - {{ $name = (index site.Params.authors .).name }} + {{ $author := index site.Params.authors $id }} + {{ $email = $author.email }} + {{ $name = $author.name }} + {{ $url = $author.url }} {{ end }} - {{ $result = $result | append (dict "id" $id "name" $name) }} + {{ $result = $result | append (dict "email" $email "id" $id "name" $name "url" $url) }} {{ end }} {{ else if site.Params.authors }} {{ range $k, $v := site.Params.authors }} {{ if eq $v.default true }} - {{ $result = $result | append (dict "id" $k "name" $v.name) }} + {{ $result = $result | append (dict "email" $v.email "id" $k "name" $v.name "url" $v.url) }} {{ end }} {{ end }} {{ end }}