Add email, url author attributes

master
Will Faught 2 years ago
parent fcb373dd79
commit 91e6ea9575

@ -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)

@ -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"

@ -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 }}

Loading…
Cancel
Save