From 122c3fc1c59f5c8c4d7431f35e083419f7984004 Mon Sep 17 00:00:00 2001 From: JP Hastings-Spital Date: Sun, 13 Aug 2023 07:56:50 +0100 Subject: [PATCH] Add last-built timestamp & helpers --- .env | 2 ++ .github/workflows/publish.yml | 5 +++++ README.md | 2 +- layouts/partials/site-last-update.html | 7 +++++++ layouts/partials/year-relative-date.html | 1 + themes/hello-friend-ng/assets/scss/_main.scss | 4 ++++ themes/hello-friend-ng/layouts/index.html | 3 ++- 7 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 .env create mode 100644 layouts/partials/site-last-update.html create mode 100644 layouts/partials/year-relative-date.html diff --git a/.env b/.env new file mode 100644 index 00000000..f6ca70c5 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +HUGO_LAST_UPDATE_TIME=$(git log -1 --format=%cI) +HUGO_LAST_UPDATE_HASH=$(git log -1 --format=%h) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 40324b17..f6b3f974 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,6 +3,10 @@ name: Deploy Hugo site to Pages on: push: branches: ["main"] + schedule: + # Rebuild at the first moment of the new year + # ensures that anywhere I'm using year-relative dates stay accurate. + - cron: '0 0 1 1 *' workflow_dispatch: @@ -49,6 +53,7 @@ jobs: HUGO_ENVIRONMENT: production HUGO_ENV: production run: | + set -o allexport; source .env; set +o allexport hugo \ --cacheDir /tmp/hugo/cache \ --minify \ diff --git a/README.md b/README.md index 3fcfb207..4b9cef10 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # byJP.me -This is the source code for my blog at https://byjp.me. It's built with [hugo](https://gohugo.io/), is built with Github Actions, and is deployed to Github's static content servers. +This is the source code for my blog at [www.byjp.me](https://wwwbyjp.me). It's built with [hugo](https://gohugo.io/), using [Github Actions](https://github.com/by-jp/www.byjp.me/blob/main/.github/workflows/publish.yml), and is deployed to both Github's static content servers and the [InterPlanetary FileSystem](https://www-byjp-me.ipns.dweb.link/). diff --git a/layouts/partials/site-last-update.html b/layouts/partials/site-last-update.html new file mode 100644 index 00000000..040d6d13 --- /dev/null +++ b/layouts/partials/site-last-update.html @@ -0,0 +1,7 @@ +{{ if or (getenv "HUGO_LAST_UPDATE_TIME") (getenv "HUGO_LAST_UPDATE_HASH") }} + + Last updated + {{ with getenv "HUGO_LAST_UPDATE_TIME" }}on {{ partial "year-relative-date.html" . }},{{ end }} + {{ with getenv "HUGO_LAST_UPDATE_HASH" }}from {{ . }}{{ end }}. + +{{ end }} diff --git a/layouts/partials/year-relative-date.html b/layouts/partials/year-relative-date.html new file mode 100644 index 00000000..da8ce945 --- /dev/null +++ b/layouts/partials/year-relative-date.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/themes/hello-friend-ng/assets/scss/_main.scss b/themes/hello-friend-ng/assets/scss/_main.scss index 989baea1..e9a123d5 100644 --- a/themes/hello-friend-ng/assets/scss/_main.scss +++ b/themes/hello-friend-ng/assets/scss/_main.scss @@ -725,4 +725,8 @@ select:focus + .focus { margin-right: 3px; text-decoration: none; display:inline-block; +} + +time:hover, abbr:hover { + border-bottom: 1px dotted; } \ No newline at end of file diff --git a/themes/hello-friend-ng/layouts/index.html b/themes/hello-friend-ng/layouts/index.html index 275a8a94..1e396020 100644 --- a/themes/hello-friend-ng/layouts/index.html +++ b/themes/hello-friend-ng/layouts/index.html @@ -23,7 +23,8 @@
{{ partial "about-me.html" .}} -
+ {{ partial "site-last-update.html" }} + {{ end }}