فهرست منبع

Fix metadata for case of multiple authors (#606)

Prateek Kumar 7 سال پیش
والد
کامیت
3c6bd89a1e
1فایلهای تغییر یافته به همراه13 افزوده شده و 6 حذف شده
  1. 13 6
      layouts/partials/article_metadata.html

+ 13 - 6
layouts/partials/article_metadata.html

@@ -2,14 +2,21 @@
 {{ $ := .content }}
 <div class="article-metadata">
 
+  {{/* If `authors` is set and is not empty. */}}
   {{ if $.Params.authors }}
   {{ $authorLen := len $.Params.authors }}
-  <div itemprop="author">
+  <div>
     {{ range $k, $v := $.Params.authors }}
-      {{- $v -}}
-      {{- if lt $k (sub $authorLen 1) -}}, {{ end }}
+    <span itemscope itemprop="author" itemtype="http://schema.org/Person">
+      <span itemprop="name">{{- $v -}}</span>
+    </span>
+    {{- if lt $k (sub $authorLen 1) -}}, {{ end }}
     {{ end }}
   </div>
+  {{ else }}
+  <span itemscope itemprop="author" itemtype="http://schema.org/Person">
+    <meta itemprop="name" content="{{ $.Site.Params.name }}">
+  </span>
   {{ end }}
 
   <span class="article-date">
@@ -21,7 +28,7 @@
       {{ $.Lastmod.Format $.Site.Params.date_format }}
     </time>
   </span>
-  <span itemscope itemprop="author publisher" itemtype="http://schema.org/Person">
+  <span itemscope itemprop="publisher" itemtype="http://schema.org/Person">
     <meta itemprop="name" content="{{ $.Site.Params.name }}">
   </span>
 
@@ -45,8 +52,8 @@
   <span class="article-categories">
     <i class="fa fa-folder"></i>
     {{ range $k, $v := $.Params.categories }}
-    <a href="{{ ($.Site.GetPage (printf "categories/%s" .)).Permalink }}">{{ . }}</a
-    >{{ if lt $k (sub $categoriesLen 1) }}, {{ end }}
+    <a href="{{ ($.Site.GetPage (printf "categories/%s" .)).Permalink }}">{{ . }}</a>
+    {{- if lt $k (sub $categoriesLen 1) -}}, {{ end }}
     {{ end }}
   </span>
   {{ end }}