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> <span>Flux RSS</span>
</a> </a>
{{ $gitinfo := readFile "data/gitinfo.txt" | split "\n" }} {{- print " · "}}
{{ $date := index $gitinfo 0 }} {{ with (readFile "data/gitinfo.txt") }}
{{ $time := index $gitinfo 1 }} {{ $raw := . }}
{{ $commit := index $gitinfo 2 }} {{ $lines := slice }}
{{ $fullcommit := index $gitinfo 3 }} {{ range split (replace $raw "\r\n" "\n") "\n" }}
<span>Mis à jour le $date à $time (Commit <a href="https://git.achilletoupin.com/gribse/blog/commit/$fullcommit"><code>{{ $commit }}</code></a></span> {{ 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> </footer>
{{- end }} {{- end }}