From 758460f25807939f9b7f43de94368d78048682ce Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Mon, 21 Dec 2020 16:38:26 -0800 Subject: [PATCH] Add date last updated (gitinfo) Add the date last updated to articles, if articles have been updated since initial publication. Incldue a link to the article changelog. --- .build.yml | 1 + Makefile | 8 ++++---- config.toml | 1 + layouts/posts/single.gmi | 9 +++++++-- .../etch-custom/layouts/_default/single.html | 20 +++++++++---------- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.build.yml b/.build.yml index b4b3935..0b14bf5 100644 --- a/.build.yml +++ b/.build.yml @@ -4,6 +4,7 @@ packages: - rsync - hugo - zopfli + - git # for Hugo's gitInfo - make sources: - https://git.sr.ht/~seirdy/seirdy.one diff --git a/Makefile b/Makefile index 71c1f0c..81c315e 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,9 @@ OUTPUT_DIR = public RSYNCFLAGS += -rlvz --zc=zstd +hugo: + hugo --gc --enableGitInfo + # .hintrc-local for linting local files # same as regular .hintrc but with a different connector. .hintrc-local: .hintrc @@ -27,13 +30,10 @@ lint: lint-css hugo .hintrc-local hint --config .hintrc-local -f codeframe $(OUTPUT_DIR) check-links: hugo - lychee --verbose $(find public -type f -name '*.html' -o -name '*.gmi' -o -name '*.txt') + lychee --verbose $(find public -type f -name '*.html' -o -name '*.gmi' -o -name '*.txt') content/posts/*.md content/posts/*.gmi test: lint check-links -hugo: - hugo --gc - build: hugo # gzip_static + max zopfli compression ifndef NO_GZIP_STATIC diff --git a/config.toml b/config.toml index df607e0..f65b8de 100644 --- a/config.toml +++ b/config.toml @@ -12,6 +12,7 @@ pygmentsUseClasses = true [params] description = "Seirdy's Home: personal website and blog for Rohan Kumar, A.K.A. Seirdy" src = "https://sr.ht/~seirdy/seirdy.one" +logUrlPrefix = "https://git.sr.ht/~seirdy/seirdy.one/log/master/item/" copyright = "Copyright © 2020 Rohan Kumar" dark = "auto" highlight = false diff --git a/layouts/posts/single.gmi b/layouts/posts/single.gmi index 4fa898b..fd2c4ee 100644 --- a/layouts/posts/single.gmi +++ b/layouts/posts/single.gmi @@ -1,10 +1,15 @@ # {{$.Title | safeHTML}} -{{ .Date.Format "2006-01-02" }} - +{{ $lastmod := .Lastmod -}} +{{ if lt .Date $lastmod -}} +Originally posted {{ .Date.Format "2006-01-02" }}. Last updated {{ .Lastmod.Format "2006-01-02" }}. +{{ else -}} +Posted {{ .Date.Format "2006-01-02" }}. +{{ end }} {{ trim (readFile (replace $.File.Path ".md" ".gmi")) "\n" | safeHTML }} --- +=> {{ .Site.Params.logUrlPrefix }}content/{{ .File.Path }} Article changelog => / Homepage{{ with .OutputFormats.Get "html" }} => {{.Permalink}} View “{{$.Title | safeHTML}}” on the WWW {{- end }} diff --git a/themes/etch-custom/layouts/_default/single.html b/themes/etch-custom/layouts/_default/single.html index 0a78df3..9a556b8 100644 --- a/themes/etch-custom/layouts/_default/single.html +++ b/themes/etch-custom/layouts/_default/single.html @@ -2,24 +2,24 @@

{{ .Title }}

- {{- if isset .Params "date" -}} - - {{- end -}} + {{ $lastmod := .Lastmod -}} + {{ if lt .Date $lastmod -}} + Originally posted . Last updated . Changelog + {{ else -}} + Posted . + {{ end }}
- {{- .Content -}} + {{ .Content -}}



- {{ end }}