From a6624c4dd9c120c105e4852f4dfa5e5723be45ad Mon Sep 17 00:00:00 2001 From: Shaform Date: Fri, 16 Nov 2018 22:15:54 -0500 Subject: fix bug and add example --- exampleSite/config.toml | 1 + exampleSite/content/en/posts/note-1.md | 2 +- exampleSite/content/zh-tw/posts/note-1.md | 2 +- exampleSite/data/authors/bob.toml | 13 +++++++++++++ layouts/posts/single.html | 4 +++- 5 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 exampleSite/data/authors/bob.toml diff --git a/exampleSite/config.toml b/exampleSite/config.toml index cef1ffe..e5a73c8 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -62,6 +62,7 @@ defaultContentLanguageInSubdir = true siteLogoImage = "images/globe.svg" # shown besides logoTitle # headerTitle = "Den" # default: title headerImage = "images/background.jpg" + showAuthorCard = true # Whether to show author information below the article showMenuLanguages = true diff --git a/exampleSite/content/en/posts/note-1.md b/exampleSite/content/en/posts/note-1.md index 1d98f73..e993803 100644 --- a/exampleSite/content/en/posts/note-1.md +++ b/exampleSite/content/en/posts/note-1.md @@ -6,7 +6,7 @@ draft: false tags: ["notes"] categories: ["Notes"] authors: -- "Shaform" +- bob --- This is a simple note. diff --git a/exampleSite/content/zh-tw/posts/note-1.md b/exampleSite/content/zh-tw/posts/note-1.md index d1e21df..b74bc7e 100644 --- a/exampleSite/content/zh-tw/posts/note-1.md +++ b/exampleSite/content/zh-tw/posts/note-1.md @@ -6,7 +6,7 @@ draft: false tags: ["notes"] categories: ["Notes"] authors: -- "Shaform" +- bob --- 這是一個簡單的筆記。 diff --git a/exampleSite/data/authors/bob.toml b/exampleSite/data/authors/bob.toml new file mode 100644 index 0000000..355f6da --- /dev/null +++ b/exampleSite/data/authors/bob.toml @@ -0,0 +1,13 @@ +url = "https://example.com" + +[name] +display = "Bob" + +[image] +# url = "" + +[zh-tw] +description = "自我簡介。" + +[en] +description = "Self introduction." diff --git a/layouts/posts/single.html b/layouts/posts/single.html index 8f42523..ea1aecb 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -9,7 +9,9 @@ {{- $last := (sub (len .Params.authors) 1) -}} {{- i18n "author_by" }} {{ range $index, $value := .Params.authors -}} - {{ (index (index $.Site.Data.authors $value) $.Site.LanguageCode).name.display | default (index $.Site.Data.authors $value).name.display | default $value }}{{ if ne $index $last }}, {{ end -}} + {{- $author := index $.Site.Data.authors $value -}} + {{- $author_lang := index ($author | default $.Site.Data.authors) $.Site.LanguageCode | default $author -}} + {{ $author_lang.name.display | default $value }}{{ if ne $index $last }}, {{ end -}} {{ end }} / {{ end }} {{ .Date.Format (.Site.Params.dateFormatToUse | default "Mon 02 January 2006") -}} -- cgit v1.2.3