aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Johnson <nick@nicksphere.ch>2022-09-16 00:00:00 +0000
committerNicholas Johnson <nick@nicksphere.ch>2022-09-16 00:00:00 +0000
commitfe2d028c74ad35151412e94697bc6db06fbeaefdc40a9d65ee707ba0e7695f89 (patch)
tree13acf3c417190f3b88ac1a4b3e51cc114a4750f4b8a08a1d847ef1a5833769b4
parent8be0f23ffbdd5d89a6122d145e67d7bf735440fc97a58f5d5e8c0f9ca3d79e45 (diff)
downloadhugo-theme-journal-fe2d028c74ad35151412e94697bc6db06fbeaefdc40a9d65ee707ba0e7695f89.tar.gz
hugo-theme-journal-fe2d028c74ad35151412e94697bc6db06fbeaefdc40a9d65ee707ba0e7695f89.zip
Conditionally add page info to top of page
-rw-r--r--TODO1
-rw-r--r--archetypes/entry.md1
-rw-r--r--layouts/_default/single.gmi3
-rw-r--r--layouts/_default/single.html2
-rw-r--r--layouts/partials/metadata.gmi6
-rw-r--r--layouts/partials/metadata.html3
-rw-r--r--layouts/partials/pageinfo2
7 files changed, 11 insertions, 7 deletions
diff --git a/TODO b/TODO
index f54193c..8e63c04 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,4 @@
- fix spacing
-- put date written and time to read somewhere in page
- add tag support
- fix "layouts/_default/single.gmi" changing preformatted text
- add support for inline elements for HTML
diff --git a/archetypes/entry.md b/archetypes/entry.md
index 46d491a..7334064 100644
--- a/archetypes/entry.md
+++ b/archetypes/entry.md
@@ -2,5 +2,6 @@
title: "{{ replace .Name "-" " " | title }}"
date: {{ dateFormat "2006-01-02T00:00:00" .Date }}
draft: true
+pageinfo: true
---
diff --git a/layouts/_default/single.gmi b/layouts/_default/single.gmi
index 5508559..5ff88c8 100644
--- a/layouts/_default/single.gmi
+++ b/layouts/_default/single.gmi
@@ -3,6 +3,9 @@
=> / 🔗 Return to homepage
+{{ if .Page.Params.pageinfo }}{{ partial "pageinfo" . }}
+
+{{ end -}}
# {{ .Name | safeHTML }}
{{ $content := .RawContent }}
{{- $content = $content | replaceRE `\n####{0,3}` "\n###" }}
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index a9fc62b..3a6ade1 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -2,6 +2,8 @@
<nav>
<p id="return"><a href="/" rel="noreferrer">🔗 Return to homepage</a></p>
</nav>
+{{- if .Page.Params.pageinfo }}
+<p>{{ partial "pageinfo" . }}</p>{{ end }}
<main>
<h1 id="{{ .File.TranslationBaseName }}">{{ .Name }}</h1>
{{ .Content -}}
diff --git a/layouts/partials/metadata.gmi b/layouts/partials/metadata.gmi
index b697ea0..368c3d3 100644
--- a/layouts/partials/metadata.gmi
+++ b/layouts/partials/metadata.gmi
@@ -1,11 +1,9 @@
{{ $entriesMinusOne := sub (len (where .Site.RegularPages.ByTitle "Section" "entry").ByPublishDate.Reverse) 1 }}
{{- range first $entriesMinusOne (where .Site.RegularPages.ByTitle "Section" "entry").ByPublishDate.Reverse }}
-{{- $dateFormat := .Site.Params.dateFormat | default "2 Jan 2006" -}}
-📆 {{ .PublishDate.Format $dateFormat | safeHTML }} | ⏱️ {{ .ReadingTime | safeHTML }} minute read
+{{- partial "pageinfo" . }}
=> .{{ .RelPermalink }} 🔗 {{ .Title | safeHTML }}
{{ end }}
{{- range last 1 (where .Site.RegularPages.ByTitle "Section" "entry").ByPublishDate.Reverse }}
-{{- $dateFormat := .Site.Params.dateFormat | default "2 Jan 2006" -}}
-📆 {{ .PublishDate.Format $dateFormat | safeHTML }} | ⏱️ {{ .ReadingTime | safeHTML }} minute read
+{{- partial "pageinfo" . }}
=> .{{ .RelPermalink }} 🔗 {{ .Title | safeHTML }}{{ end }}
diff --git a/layouts/partials/metadata.html b/layouts/partials/metadata.html
index be9897b..844ea12 100644
--- a/layouts/partials/metadata.html
+++ b/layouts/partials/metadata.html
@@ -1,8 +1,7 @@
{{ range (where .Site.RegularPages.ByTitle "Section" "entry").ByPublishDate.Reverse -}}
-{{ $dateFormat := .Site.Params.dateFormat | default "2 Jan 2006" -}}
<article>
<header>
- <p>📆 {{ .PublishDate.Format $dateFormat }} | ⏱️ {{ .ReadingTime }} minute read<br>
+ <p>{{ partial "pageinfo" . }}<br>
<a href="{{ .RelPermalink }}" rel="noreferrer">🔗 {{ .Title }}</a></p>
</header>
</article>
diff --git a/layouts/partials/pageinfo b/layouts/partials/pageinfo
new file mode 100644
index 0000000..c512b88
--- /dev/null
+++ b/layouts/partials/pageinfo
@@ -0,0 +1,2 @@
+{{ $dateFormat := .Site.Params.dateFormat | default "2 Jan 2006" -}}
+📆 {{ .Page.PublishDate.Format $dateFormat | safeHTML }} | ⏱️ {{ .Page.ReadingTime | safeHTML }} minute read \ No newline at end of file