Add authors taxonomy

master
Will Faught 2 years ago
parent a66f33962c
commit 062c45579d

@ -26,22 +26,26 @@ languages:
name: "Customization" name: "Customization"
url: "/customization/" url: "/customization/"
weight: 50 weight: 50
- identifier: "authors"
name: "Authors"
url: "/authors/"
weight: 60
- identifier: "series" - identifier: "series"
name: "Series" name: "Series"
url: "/series/" url: "/series/"
weight: 60 weight: 70
- identifier: "categories" - identifier: "categories"
name: "Categories" name: "Categories"
url: "/categories/" url: "/categories/"
weight: 70 weight: 80
- identifier: "tags" - identifier: "tags"
name: "Tags" name: "Tags"
url: "/tags/" url: "/tags/"
weight: 80 weight: 90
- identifier: "search" - identifier: "search"
name: "Search" name: "Search"
url: "/search/" url: "/search/"
weight: 90 weight: 100
weight: 10 weight: 10
markup: markup:
goldmark: goldmark:
@ -67,6 +71,7 @@ params:
git: git:
commit_url_prefix: "https://github.com/willfaught/paige/commit/" commit_url_prefix: "https://github.com/willfaught/paige/commit/"
taxonomies: taxonomies:
author: "authors"
category: "categories" category: "categories"
series: "series" series: "series"
tag: "tags" tag: "tags"

@ -0,0 +1,4 @@
---
description: "Demonstration of an author."
title: "Will Faught"
---

@ -46,7 +46,13 @@
{{ range $pages }} {{ range $pages }}
<item> <item>
{{ with partial "paige/authors.html" . }} {{ with partial "paige/authors.html" . }}
<author>{{ . }}</author> {{ $authors := slice }}
{{ range . }}
{{ $authors = $authors | append .name }}
{{ end }}
<author>{{ delimit $authors ", " }}</author>
{{ end }} {{ end }}
{{ if .Content }} {{ if .Content }}
<description>{{ printf "<![CDATA[%s]]>" .Content | safeHTML }}</description> <description>{{ printf "<![CDATA[%s]]>" .Content | safeHTML }}</description>

@ -1,33 +1,32 @@
{{ $page := . }} {{ $page := . }}
{{ $result := "" }} {{ $result := slice }}
{{ if $page.Params.authors }} {{ if $page.Params.authors }}
{{ $names := slice }}
{{ range $page.Params.authors }} {{ range $page.Params.authors }}
{{ if eq (printf "%T" .) "string" }} {{ $id := "" }}
{{ $names = $names | append (index site.Params.authors .).name }} {{ $name := "" }}
{{ else }}
{{ if reflect.IsMap . }}
{{ with .author }} {{ with .author }}
{{ $names = $names | append (index site.Params.authors .).name }} {{ $id = . }}
{{ $name = (index site.Params.authors .).name }}
{{ else }} {{ else }}
{{ $names = $names | append .name }} {{ $name = .name }}
{{ end }}
{{ end }} {{ end }}
{{ else }}
{{ $id = . }}
{{ $name = (index site.Params.authors .).name }}
{{ end }} {{ end }}
{{ $result = delimit $names ", " }} {{ $result = $result | append (dict "id" $id "name" $name) }}
{{ end }}
{{ else if site.Params.authors }} {{ else if site.Params.authors }}
{{ $names := slice }}
{{ range $k, $v := site.Params.authors }} {{ range $k, $v := site.Params.authors }}
{{ if eq $v.default true }} {{ if eq $v.default true }}
{{ $names = $names | append $v.name }} {{ $result = $result | append (dict "id" $k "name" $v.name) }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ $result = delimit $names ", " }}
{{ end }} {{ end }}
{{ return $result }} {{ return $result }}

@ -72,7 +72,21 @@
{{ end }} {{ end }}
{{ with $authors }} {{ with $authors }}
<p class="mb-0 {{ if $class }} paige-authors {{ end }} text-center text-secondary" {{ if $id }} id="paige-authors" {{ end }}>{{ . }}</p> <p class="mb-0 {{ if $class }} paige-authors {{ end }} text-center text-secondary" {{ if $id }} id="paige-authors" {{ end }}>
{{ range $i, $author := . -}}
{{- if gt $i 0 }}, {{ end -}}
{{- with $author.id -}}
{{- with site.GetPage (print "authors/" .) -}}
<a class="link-secondary text-decoration-none" href="{{ .RelPermalink }}">{{ .Title | default $author.name }}</a>
{{- else -}}
{{- $author.name -}}
{{- end -}}
{{- else -}}
{{- $author.name -}}
{{- end -}}
{{- end }}
</p>
{{ end }} {{ end }}
{{ with $date }} {{ with $date }}

@ -90,7 +90,21 @@
{{ end }} {{ end }}
{{ with $authors }} {{ with $authors }}
<p class="mb-0 paige-authors text-center text-secondary">{{ . }}</p> <p class="mb-0 paige-authors text-center text-secondary">
{{ range $i, $author := . -}}
{{- if gt $i 0 }}, {{ end -}}
{{- with $author.id -}}
{{- with site.GetPage (print "authors/" .) -}}
<a class="link-secondary text-decoration-none" href="{{ .RelPermalink }}">{{ .Title | default $author.name }}</a>
{{- else -}}
{{- $author.name -}}
{{- end -}}
{{- else -}}
{{- $author.name -}}
{{- end -}}
{{- end }}
</p>
{{ end }} {{ end }}
{{ with $date }} {{ with $date }}

Loading…
Cancel
Save