Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions layouts/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
{{- /* Add author pages to index so their bios can be searched. Hide empty `/authors/` node. */ -}}
{{- $pages := $pages | union (where (where site.Pages "Section" "authors") "Params.superuser" "!=" nil) -}}

{{- $author_map := dict -}}
{{- range where site.Pages "Section" "authors" -}}
{{- /* Determine the author username by looking at the directory or file name */ -}}
{{- $username := lower (path.Base (strings.TrimSuffix "/_index.md" (strings.TrimSuffix "/_index.markdown" (strings.TrimSuffix ".md" (strings.TrimSuffix ".markdown" .Path))))) -}}
{{- if and .Title .File -}}
{{- $author_map = merge $author_map (dict $username .Title) -}}
{{- end -}}
{{- end -}}

{{- range $pages -}}
{{- /* Do not index drafts or private pages. */ -}}
{{- if and (not .Draft) (not .Params.private) -}}
Expand Down Expand Up @@ -44,10 +53,9 @@
{{- if gt $authorLen 0 -}}
{{- $authors = slice -}}
{{- range $k, $v := .Params.authors -}}
{{- $person_page_path := (printf "/authors/%s" (urlize $v)) -}}
{{- $person_page := site.GetPage $person_page_path -}}
{{- if and $person_page $person_page.File -}}
{{- $authors = $authors | append $person_page.Title -}}
{{- $author_username := urlize $v -}}
{{- if isset $author_map $author_username -}}
{{- $authors = $authors | append (index $author_map $author_username) -}}
{{- else -}}
{{- $authors = $authors | append ($v | plainify) -}}
{{- end -}}
Expand Down