浏览代码

If no author specified in blog post, it should default to site author (#6)

* Author name should default to site author 

If author name is not present in the blog post it should default to site author

* Default to site author

If author image is not present in the blog post, it should default to the site author
Jean-Baptiste Le Duigou 4 年之前
父节点
当前提交
5517dae23a
共有 2 个文件被更改,包括 6 次插入0 次删除
  1. 3 0
      layouts/partials/helpers/get-author-image.html
  2. 3 0
      layouts/partials/helpers/get-author-name.html

+ 3 - 0
layouts/partials/helpers/get-author-image.html

@@ -1,4 +1,7 @@
 {{ $authorImage:= "/assets/images/default-avatar.png"}}
 {{ $authorImage:= "/assets/images/default-avatar.png"}}
+{{ if .Site.Data.site.author}}
+    {{ $authorImage = .Site.Data.site.author.image | relURL }}
+{{ end}}
 {{ if eq (printf "%T" .Params.author ) "maps.Params" }}
 {{ if eq (printf "%T" .Params.author ) "maps.Params" }}
     {{ with .Params.author }}
     {{ with .Params.author }}
         {{ if .image }}
         {{ if .image }}

+ 3 - 0
layouts/partials/helpers/get-author-name.html

@@ -1,4 +1,7 @@
 {{ $authorName:= "John Doe"}}
 {{ $authorName:= "John Doe"}}
+{{ if .Site.Data.site.author}}
+    {{ $authorName = .Site.Data.site.author.name }}
+{{ end}}
 {{ if eq (printf "%T" .Params.author ) "maps.Params" }}
 {{ if eq (printf "%T" .Params.author ) "maps.Params" }}
     {{ with .Params.author }}
     {{ with .Params.author }}
         {{ if .name }}
         {{ if .name }}