fix: update footer to read git information with error handling
Some checks are pending
/ test (push) Waiting to run

This commit is contained in:
gribse 2025-05-15 22:01:50 +02:00
parent a0f361e2e1
commit f0f03b1e64
2 changed files with 26 additions and 7 deletions

4
data/gitinfo.txt Normal file
View file

@ -0,0 +1,4 @@
2025-05-15
21:31
a0f361e
a0f361e2e17c0027b08aa9bc3ae7ccfa47349b1b

View file

@ -24,13 +24,28 @@
<span>Flux RSS</span>
</a>
{{ $gitinfo := readFile "data/gitinfo.txt" | split "\n" }}
{{ $date := index $gitinfo 0 }}
{{ $time := index $gitinfo 1 }}
{{ $commit := index $gitinfo 2 }}
{{ $fullcommit := index $gitinfo 3 }}
<span>Mis à jour le $date à $time (Commit <a href="https://git.achilletoupin.com/gribse/blog/commit/$fullcommit"><code>{{ $commit }}</code></a></span>
{{- print " · "}}
{{ with (readFile "data/gitinfo.txt") }}
{{ $raw := . }}
{{ $lines := slice }}
{{ range split (replace $raw "\r\n" "\n") "\n" }}
{{ if ne . "" }}
{{ $lines = $lines | append . }}
{{ end }}
{{ end }}
{{ if ge (len $lines) 4 }}
<span>
Mis à jour le {{ index $lines 0 }} à {{ index $lines 1 }}
(Commit <a href="https://git.achilletoupin.com/gribse/blog/commit/{{ index $lines 3 }}"><code>{{ index $lines 2 }}</code></a>)
</span>
{{ else }}
<span>Information de mise à jour non disponible</span>
{{ end }}
{{ else }}
<span>Fichier gitinfo non trouvé</span>
{{ end }}
</footer>
{{- end }}