瀏覽代碼

fix: workaround Hugo Page.GetTerms bug

Hugo bug causes authors not to be listed in the order in which they were defined in the front matter.

See Hugo bug report at https://github.com/gohugoio/hugo/issues/7213

This commit partially reverts f78feefee90e02ba2d9f06242f4d735dc0271fbf where the code was refactored to use Page.GetTerms for authors.
George Cushen 5 年之前
父節點
當前提交
48b39f8550
共有 1 個文件被更改,包括 6 次插入7 次删除
  1. 6 7
      layouts/partials/page_metadata_authors.html

+ 6 - 7
layouts/partials/page_metadata_authors.html

@@ -1,18 +1,17 @@
 {{/* Display author list. */}}
 
 {{- $taxonomy := "authors" }}
-{{ if .Param $taxonomy }}
+{{ with .Param $taxonomy }}
   {{ $link_authors := site.Params.link_authors | default true }}
-  {{ range $index, $value := (.GetTerms $taxonomy) }}
-    {{- /* Check if a profile was created for this user. */ -}}
-    {{- $profile_page := isset .Page.Params "superuser" -}}
-
+  {{ range $index, $name_raw := . }}
+    {{- $profile_page := site.GetPage (printf "/%s/%s" $taxonomy .) -}}
+    {{- $name := $profile_page.Title | default $name_raw -}}
     {{- if gt $index 0 }}, {{ end -}}
     <span>
       {{- if and $profile_page $link_authors -}}
-        <a href="{{.RelPermalink}}">{{ .LinkTitle }}</a>
+        <a href="{{$profile_page.RelPermalink}}">{{$name}}</a>
       {{- else -}}
-        {{ .LinkTitle }}
+        {{$name}}
       {{- end -}}
     </span>
   {{- end -}}