diff --git a/README.md b/README.md index 70fcd739..6946df4d 100644 --- a/README.md +++ b/README.md @@ -64,11 +64,6 @@ googleAnalytics = "" # DEPRECATED! Use .Services.googleAnalytics.ID [services.googleAnalytics] ID = "" # Enable Google Analytics by entering your tracking ID -[Author] # Used in authorbox - name = "John Doe" - bio = "John Doe's true identity is unknown. Maybe he is a successful blogger or writer. Nobody knows it." - avatar = "img/avatar.png" - [Params] description = "John Doe's Personal blog about everything" # Site description. Used in meta description copyright = "John Doe" # Footer copyright holder, otherwise will use site title @@ -159,6 +154,22 @@ googleAnalytics = "" # DEPRECATED! Use .Services.googleAnalytics.ID For more information about all available standard configuration settings, please read [All Hugo Configuration Settings](https://gohugo.io/getting-started/configuration/#all-configuration-settings). +### Authorbox + +Create a file at `data/authors/earnestfreeguy.json`. Add the following contents to it: + +```json +{ + "name": "Earnest Freeguy", + "avatar": "img/avatar-earnestfreeguy.png", + "bio": "Earnest cares a lot about Liberty. He likes to spend his time blogging, drinking fair-trade coffee, and eating his cats.", +} +``` + +Then make sure to include "author: earnestfreeguy" in the Front Matter for a given post. +The Authorbox will use `earnestfreeguy` to look up the data entry, then pull the +various values for that author into the Authorbox. + ### Front Matter example ```yaml diff --git a/layouts/partials/authorbox.html b/layouts/partials/authorbox.html index 20d6dfec..661901a2 100644 --- a/layouts/partials/authorbox.html +++ b/layouts/partials/authorbox.html @@ -1,24 +1,35 @@ {{- if .Param "authorbox" }}
- {{- if and (not .Site.Author.avatar) (not .Site.Author.name) (not .Site.Author.bio) }} -

- WARNING: Authorbox is activated, but [Author] parameters are not specified. -

- {{- end }} - {{- with .Site.Author.avatar }} -
- {{ $.Site.Author.name }} avatar -
- {{- end }} - {{- with .Site.Author.name }} -
- {{ T "authorbox_name" (dict "Name" .) }} -
- {{- end }} - {{- with .Site.Author.bio }} -
- {{ . | markdownify }} -
+ {{ $author := default .Site.Author (index .Site.Data.authors (.Params.author | default "default")) }} + {{- with $author }} + {{- if (not $author.avatar) }} +

+ WARNING: Authorbox is activated, but author is missing the "avatar" property. +

+ {{- end }} + {{- if (not $author.name) }} +

+ WARNING: Authorbox is activated, but author is missing the "name" property. + if (not $author.bio) }} +

+ WARNING: Authorbox is activated, but author is missing the "bio" property. +

+ {{- end }} + {{- with $author.avatar }} +
+ {{ $author.name }} avatar +
+ {{- end }} + {{- with $author.name }} +
+ {{ T "authorbox_name" (dict "Name" .) }} +
+ {{- end }} + {{- with $author.bio }} +
+ {{ . | markdownify }} +
+ {{- end }} {{- end }}
{{- end }} \ No newline at end of file