Add last-built timestamp & helpers

This commit is contained in:
JP Hastings-Spital 2023-08-13 07:56:50 +01:00
parent 58e22e47ad
commit 122c3fc1c5
7 changed files with 22 additions and 2 deletions

2
.env Normal file
View file

@ -0,0 +1,2 @@
HUGO_LAST_UPDATE_TIME=$(git log -1 --format=%cI)
HUGO_LAST_UPDATE_HASH=$(git log -1 --format=%h)

View file

@ -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 \

View file

@ -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/).

View file

@ -0,0 +1,7 @@
{{ if or (getenv "HUGO_LAST_UPDATE_TIME") (getenv "HUGO_LAST_UPDATE_HASH") }}
<small style="font-style:italic">
Last updated
{{ with getenv "HUGO_LAST_UPDATE_TIME" }}on {{ partial "year-relative-date.html" . }},{{ end }}
{{ with getenv "HUGO_LAST_UPDATE_HASH" }}from <a href="https://github.com/by-jp/www.byjp.me/tree/{{ . }}">{{ . }}</a>{{ end }}.
</small>
{{ end }}

View file

@ -0,0 +1 @@
<time timestamp="{{ . }}" title="{{ time . | dateFormat "2006-01-02 03:04 MST" }}">{{ time . | dateFormat "January 2" }}{{ if ne (time . | dateFormat "2006") (now | dateFormat "2006") }} {{ now | dateFormat "2006" }}{{ end }}</time>

View file

@ -725,4 +725,8 @@ select:focus + .focus {
margin-right: 3px;
text-decoration: none;
display:inline-block;
}
time:hover, abbr:hover {
border-bottom: 1px dotted;
}

View file

@ -23,7 +23,8 @@
<hr />
<section class="posts" style="text-align:center">
{{ partial "about-me.html" .}}
</section>
{{ partial "site-last-update.html" }}
</section>
</main>
{{ end }}