diff options
author | Shaform <shaform@gmail.com> | 2018-11-17 06:00:07 +0300 |
---|---|---|
committer | Shaform <shaform@gmail.com> | 2018-11-17 06:00:07 +0300 |
commit | 0ebd7323f87e083cfa957801c5a4849f120b0527 (patch) | |
tree | 2779e28d4f7ecc1377c6432318103b0ffa783e55 | |
parent | 93536adba00dd2dabde35c660253353ddf86724a (diff) |
support author information
-rw-r--r-- | i18n/en.yaml | 3 | ||||
-rw-r--r-- | i18n/zh-tw.yaml | 3 | ||||
-rw-r--r-- | layouts/partials/author_card.html | 24 | ||||
-rw-r--r-- | layouts/posts/single.html | 7 | ||||
-rw-r--r-- | static/css/den.css | 40 | ||||
-rw-r--r-- | static/images/blank-profile.png | bin | 0 -> 19288 bytes |
6 files changed, 76 insertions, 1 deletions
diff --git a/i18n/en.yaml b/i18n/en.yaml index 5c1f72f..859d5c7 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -76,3 +76,6 @@ - id: translations translation: "Translations: " + +- id: author + translation: Author diff --git a/i18n/zh-tw.yaml b/i18n/zh-tw.yaml index d84903b..9300251 100644 --- a/i18n/zh-tw.yaml +++ b/i18n/zh-tw.yaml @@ -76,3 +76,6 @@ - id: translations translation: "翻譯: " + +- id: author + translation: 作者 diff --git a/layouts/partials/author_card.html b/layouts/partials/author_card.html new file mode 100644 index 0000000..d795525 --- /dev/null +++ b/layouts/partials/author_card.html @@ -0,0 +1,24 @@ +{{- with $author := index .context.Site.Data.authors .author -}} + {{- $author_lang := index $author $.context.Site.LanguageCode | default $author -}} + {{- $author_name := $author_lang.name.display | default $author.name.display | default $.author -}} + {{- $author_desc := $author_lang.description | default $author.description | default $.author -}} + {{- $author_image := $author_lang.image.url | default $author.image.url | default "images/blank-profile.png" -}} + {{- $author_url := $author_lang.url | default $author.url -}} + <div class="author-card"> + <div class="underline"></div> + <div class="author-box"> + <div class="author-image"> + {{- with $author_url -}} + <a href="{{ $author_url | relURL }}"><img src="{{ $author_image | relURL }}" /></a> + {{- else -}} + <img src="{{ $author_image | relURL }}" /> + {{- end -}} + </div> + <div class="author-content"> + <p class="author-title">{{ i18n "author" }}</p> + <p class="author-name">{{ $author_name }}</p> + <p class="author-desc">{{ $author_desc }}</p> + </div> + </div> + </div> +{{- end -}} diff --git a/layouts/posts/single.html b/layouts/posts/single.html index 5f6a191..8f42523 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -9,7 +9,7 @@ {{- $last := (sub (len .Params.authors) 1) -}} {{- i18n "author_by" }} {{ range $index, $value := .Params.authors -}} - {{ $value }}{{ if ne $index $last }}, {{ end -}} + {{ (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 -}} {{ end }} / {{ end }} {{ .Date.Format (.Site.Params.dateFormatToUse | default "Mon 02 January 2006") -}} @@ -71,6 +71,11 @@ </dl> {{ end }} {{ end }} + {{ if (.Params.showAuthorCard | default .Site.Params.showAuthorCard) }} + {{ range .Params.authors }} + {{ partial "author_card.html" (dict "author" . "context" $) }} + {{ end }} + {{ end }} {{ partial "comments.html" . }} </div> {{ end }} diff --git a/static/css/den.css b/static/css/den.css index aede86c..33f4326 100644 --- a/static/css/den.css +++ b/static/css/den.css @@ -473,6 +473,46 @@ blockquote{ font-size: 15px; opacity: 0.65; } +/* Author Card */ +.container .author-card { + text-align: center; +} +.container .author-card .author-content { + text-align: left; +} +.container .author-card .author-title { + color: #aaa; + margin-bottom: 0.1em; +} +.container .author-card .author-name { + font-weight: bold; + margin-bottom: 0.5em; +} +.container .author-card .author-desc { + font-size: 0.8em; +} +.container .author-card .author-box { + padding: 1em; +} +.container .author-card .author-box .author-content { + padding-left: 160px; +} +.container .author-card .author-box .author-image img { + margin: 0 auto; + border-radius: 50%; + border: 1px solid #999; + float: left; + width: 128px; + height: 128px; +} +.container .underline { + display: inline-block; + margin-top: 10px; + margin-bottom: 15px; + width: 50px; + border-bottom: 3px solid #eb2344; +} + /* Comments */ .comments{ margin-top: 40px; diff --git a/static/images/blank-profile.png b/static/images/blank-profile.png Binary files differnew file mode 100644 index 0000000..cfe3647 --- /dev/null +++ b/static/images/blank-profile.png |