Skip to content

Commit 60c94dc

Browse files
committed
Add author/category taxonomies and CMS collections
- Register `authors` and `categories` taxonomies in config - Add author term layout with bio, avatar, socials, and post list - Override `post_meta` partial to link authors to their taxonomy pages - Add Decap CMS collections for authors, categories, pages, and posts - Switch author/category fields in posts to relation widgets - Add `sunday-lessons` category seed file
1 parent ea50513 commit 60c94dc

6 files changed

Lines changed: 153 additions & 6 deletions

File tree

‎config.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ metaDataFormat: yaml
1010
pygmentsUseClasses: true
1111
pygmentCodeFences: true
1212
enableRobotsTXT: true
13+
taxonomies:
14+
category: categories
15+
author: authors
1316
module:
1417
imports:
1518
- path: github.com/halogenica/beautifulhugo
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: Sunday Lessons

‎go.sum‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
github.com/KKKZOZ/hugo-admonitions v0.12.0 h1:x74ZrNUCrySH5JHPO2qGx+b1Mz8r+F1rBlH9qM833io=
22
github.com/KKKZOZ/hugo-admonitions v0.12.0/go.mod h1:4PsJAsqo3mS3VzAtDLa8k0ds+CJQUWZhAo9kLi1NRlM=
3-
github.com/halogenica/beautifulhugo v0.0.0-20250508050025-e69e25d4ca0d h1:H3Gf3B7nxMscrz+v7fn+PavLMUR+vCpcRJpzCAZy57A=
4-
github.com/halogenica/beautifulhugo v0.0.0-20250508050025-e69e25d4ca0d/go.mod h1:4dwHt6njigk+fr9W3Bg+OflL4LKzkjbXAULXvr3mYLs=
53
github.com/halogenica/beautifulhugo v0.0.0-20260331144909-84b4ad9e12e6 h1:KSNmuzV0Ry7mawT/WP8VI8h10mwBcqvq+2TOVF2zA+A=
64
github.com/halogenica/beautifulhugo v0.0.0-20260331144909-84b4ad9e12e6/go.mod h1:4dwHt6njigk+fr9W3Bg+OflL4LKzkjbXAULXvr3mYLs=

‎layouts/authors/term.html‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{ define "main" }}
2+
<article>
3+
<header>
4+
{{ with .Params.avatar }}<img src="{{ . }}" alt="" class="author-avatar">{{ end }}
5+
<h1>{{ .Title }}</h1>
6+
</header>
7+
8+
{{ with .Content }}<div class="author-bio">{{ . }}</div>{{ end }}
9+
10+
<ul class="author-socials">
11+
{{ with .Params.github }}<li><a href="https://github.com/{{ . }}">GitHub</a></li>{{ end }}
12+
{{ with .Params.twitter }}<li><a href="https://x.com/{{ . }}">Twitter</a></li>{{ end }}
13+
{{ with .Params.bluesky }}<li><a href="https://bsky.app/profile/{{ . }}">Bluesky</a></li>{{ end }}
14+
{{ with .Params.website }}<li><a href="{{ . }}">Website</a></li>{{ end }}
15+
{{ with .Params.discord }}<li>Discord: {{ . }}</li>{{ end }}
16+
</ul>
17+
18+
<h2>Posts by {{ .Title }}</h2>
19+
<ul>
20+
{{ range .Pages.ByDate.Reverse }}
21+
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a> <small>{{ .Date.Format "2006-01-02" }}</small></li>
22+
{{ end }}
23+
</ul>
24+
</article>
25+
{{ end }}

‎layouts/partials/post_meta.html‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<span class="post-meta">
2+
{{ $format := default (i18n "dateFormat") .Site.Params.dateformat }}
3+
{{ $datestr := .Date.Format $format }}
4+
{{ $lastmodstr := .Lastmod.Format $format }}
5+
<i class="fas fa-calendar"></i>&nbsp;{{ $datestr | i18n "postedOnDate"}}
6+
{{ if ne $datestr $lastmodstr }}
7+
&nbsp;({{ $lastmodstr | i18n "lastModified" }})
8+
{{ end }}
9+
{{ if .Site.Params.readingTime }}
10+
&nbsp;|&nbsp;<i class="fas fa-clock"></i>&nbsp;{{ i18n "readingTime"}}{{ .ReadingTime }}&nbsp;{{ i18n "readTime" }}
11+
{{ end }}
12+
{{ if .Site.Params.wordCount }}
13+
&nbsp;|&nbsp;<i class="fas fa-book"></i>&nbsp;{{ .WordCount }}&nbsp;{{ i18n "words" }}
14+
{{ end }}
15+
{{ if not .Site.Params.hideAuthor }}
16+
{{ if .Params.authors }}
17+
{{ range .Params.authors }}
18+
{{ $authorPage := $.Site.GetPage (printf "/authors/%s" .) }}
19+
{{ if $authorPage }}
20+
&nbsp;|&nbsp;<i class="fas fa-user"></i>&nbsp;<a href="{{ $authorPage.RelPermalink }}">{{ $authorPage.Title }}</a>
21+
{{ else }}
22+
&nbsp;|&nbsp;<i class="fas fa-user"></i>&nbsp;{{ . }}
23+
{{ end }}
24+
{{ end }}
25+
{{ else if .Params.author }}
26+
{{ if reflect.IsSlice .Params.author }}
27+
{{ range .Params.author }}
28+
&nbsp;|&nbsp;<i class="fas fa-user"></i>&nbsp;{{ . | safeHTML }}
29+
{{ end }}
30+
{{ else }}
31+
&nbsp;|&nbsp;<i class="fas fa-user"></i>&nbsp;{{ .Params.author | safeHTML }}
32+
{{ end }}
33+
{{ else }}
34+
&nbsp;|&nbsp;<i class="fas fa-user"></i>&nbsp;{{ .Site.Params.author.name | safeHTML }}
35+
{{ end }}
36+
{{ end }}
37+
{{- if .Site.Params.staticman -}}
38+
&nbsp;|&nbsp;<i class="fas fa-comment"></i>&nbsp;
39+
{{ $slug := replace .RelPermalink "/" "" }}
40+
{{ if .Site.Data.comments }}
41+
{{ $comments := index $.Site.Data.comments $slug }}
42+
{{ if $comments }}
43+
{{ if gt (len $comments) 1 }}
44+
{{ len $comments }} {{ i18n "moreComment" }}
45+
{{ else }}
46+
{{ len $comments }} {{ i18n "oneComment" }}
47+
{{ end }}
48+
{{ else }}
49+
0 {{ i18n "oneComment" }}
50+
{{ end }}
51+
{{ end }}
52+
{{ end }}
53+
{{ if .IsTranslated -}}
54+
{{- $sortedTranslations := sort .Translations "Site.Language.Weight" -}}
55+
{{- $links := apply $sortedTranslations "partial" "translation_link.html" "." -}}
56+
{{- $cleanLinks := apply $links "chomp" "." -}}
57+
{{- $linksOutput := delimit $cleanLinks (i18n "translationsSeparator") -}}
58+
&nbsp;&bull;&nbsp;{{ i18n "translationsLabel" }}{{ $linksOutput | safeHTML }}
59+
{{- end }}
60+
</span>

‎static/admin/config.yml‎

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,51 @@ media_folder: /static/images
77
public_folder: /images
88

99
collections:
10+
- name: categories
11+
label: Categories
12+
folder: content/categories
13+
format: yml
14+
create: true
15+
delete: true
16+
fields:
17+
- label: "Title"
18+
name: "title"
19+
widget: "string"
20+
21+
- name: authors
22+
label: Authors
23+
folder: content/authors
24+
path: "{{slug}}/_index"
25+
format: yaml-frontmatter
26+
extension: md
27+
create: true
28+
delete: true
29+
fields:
30+
- { label: "Name", name: "title", widget: "string" }
31+
- { label: "Avatar", name: "avatar", widget: "image", required: false }
32+
- { label: "GitHub", name: "github", widget: "string", required: false, hint: "username only" }
33+
- { label: "Twitter/X", name: "twitter", widget: "string", required: false, hint: "handle only" }
34+
- { label: "Bluesky", name: "bluesky", widget: "string", required: false, hint: "e.g. name.bsky.social" }
35+
- { label: "Website", name: "website", widget: "string", required: false, hint: "full URL" }
36+
- { label: "Discord", name: "discord", widget: "string", required: false }
37+
- { label: "Bio", name: "body", widget: "markdown" }
38+
39+
- name: pages
40+
label: Pages
41+
folder: content/page
42+
create: true
43+
delete: true
44+
fields:
45+
- label: "Title"
46+
name: "title"
47+
widget: "string"
48+
- label: "Draft"
49+
name: "draft"
50+
widget: "boolean"
51+
- label: "Body"
52+
name: "body"
53+
widget: "richtext"
54+
1055
- name: posts
1156
label: Posts
1257
folder: content/post
@@ -18,10 +63,18 @@ collections:
1863
- label: "Subtitle"
1964
name: "subtitle"
2065
widget: "string"
66+
required: false
2167

22-
- label: "Author"
23-
name: "author"
24-
widget: "string"
68+
- label: "Authors"
69+
label_singular: "Author"
70+
name: "authors"
71+
widget: "relation"
72+
multiple: true
73+
collection: "authors"
74+
search_fields: ["title"]
75+
display_fields: ["title"]
76+
value_field: "{{slug}}"
77+
required: false
2578

2679
- label: "Date"
2780
name: "date"
@@ -33,8 +86,15 @@ collections:
3386
widget: "boolean"
3487

3588
- label: "Categories"
89+
label_singular: "Category"
3690
name: "categories"
37-
widget: "list"
91+
widget: "relation"
92+
multiple: true
93+
collection: "categories"
94+
search_fields: ["title"]
95+
display_fields: ["title"]
96+
value_field: "{{slug}}"
97+
3898

3999
- label: "Body"
40100
name: "body"

0 commit comments

Comments
 (0)