From 3fc0dba4012108749f433da017d9e02cf64b6503 Mon Sep 17 00:00:00 2001
From: Patrick Kollitsch <patrick@davids-neighbour.com>
Date: Sun, 09 Feb 2025 08:55:24 +0000
Subject: [PATCH] theme(fix): add author bylines and fix author generation
---
exampleSite/config.toml | 2 +-
layouts/_default/single.html | 3 ++-
layouts/_default/summary-with-image.html | 7 ++++---
layouts/partials/summary-with-image.html | 7 ++++---
layouts/partials/author.html | 0
exampleSite/content/en/post/chapter-6.md | 1 +
6 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index fa1ec9f..8be3166 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -33,7 +33,7 @@
[params]
text_color = ""
-author = ""
+author = "Victor Hugo" # default author, override via `author` in a posts front matter
favicon = ""
site_logo = ""
description = "The last theme you'll ever need. Maybe."
diff --git a/exampleSite/content/en/post/chapter-6.md b/exampleSite/content/en/post/chapter-6.md
index c767196..86e1ab7 100644
--- a/exampleSite/content/en/post/chapter-6.md
+++ b/exampleSite/content/en/post/chapter-6.md
@@ -4,6 +4,7 @@
featured_image: "/images/esmeralda.jpg"
tags: []
title: "Chapter VI: Esmeralda"
+author: "Victor Hugo"
---
We are delighted to be able to inform the reader, that during the whole of
this scene, Gringoire and his piece had stood firm. His actors, spurred on
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index c7c2b13..89a2407 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -4,6 +4,7 @@
{{ end }}
{{ define "main" }}
+ {{ $page := .}}
{{ $section := .Site.GetPage "section" .Section }}
<article class="flex-l flex-wrap justify-between mw8 center ph3">
<header class="mt4 w-100">
@@ -20,7 +21,7 @@
</h1>
{{ with .Params.author | default .Site.Params.author }}
<p class="tracked">
- {{- if eq .Lang "de" "en" "es" "fr" "it" "no" "pt" -}}
+ {{- if eq $page.Language "de" "en" "es" "fr" "it" "no" "pt" -}}
{{- i18n "by" -}}
{{ end -}} <strong>
{{- if reflect.IsSlice . -}}
diff --git a/layouts/_default/summary-with-image.html b/layouts/_default/summary-with-image.html
index 0467891..d6a88ce 100644
--- a/layouts/_default/summary-with-image.html
+++ b/layouts/_default/summary-with-image.html
@@ -19,9 +19,10 @@
<div class="f6 f5-l lh-copy nested-copy-line-height nested-links">
{{ .Summary }}
</div>
- <a href="{{.RelPermalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">{{ $.Param "read_more_copy" | default (i18n "readMore") }}</a>
- {{/* TODO: add author
- <p class="f6 lh-copy mv0">By {{ .Author }}</p> */}}
+ {{ with .Params.author | default .Site.Params.author }}
+ <p class="f6 lh-copy mv0">By {{ . }}</p>
+ {{- end -}}
+ <a href="{{.RelPermalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">{{ $.Param "read_more_copy" | default (i18n "readMore") }}</a>
</div>
</div>
</div>
diff --git a/layouts/partials/author.html b/layouts/partials/author.html
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/layouts/partials/author.html
diff --git a/layouts/partials/summary-with-image.html b/layouts/partials/summary-with-image.html
index 0be1b39..42a21e4 100644
--- a/layouts/partials/summary-with-image.html
+++ b/layouts/partials/summary-with-image.html
@@ -22,9 +22,10 @@
<div class="f6 f5-l lh-copy nested-copy-line-height nested-links">
{{ .Summary }}
</div>
- <a href="{{.RelPermalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">{{ $.Param "read_more_copy" | default (i18n "readMore") }}</a>
- {{/* TODO: add author
- <p class="f6 lh-copy mv0">By {{ .Author }}</p> */}}
+ {{ with .Params.author | default .Site.Params.author }}
+ <p class="f6 lh-copy mv0">By {{ . }}</p>
+ {{- end -}}
+ <a href="{{.RelPermalink}}" class="ba b--moon-gray bg-light-gray br2 color-inherit dib f7 hover-bg-moon-gray link mt2 ph2 pv1">{{ $.Param "read_more_copy" | default (i18n "readMore") }}</a>
</div>
</div>
</div>
--
Gitblit v1.10.0