Added post age warning

This commit is contained in:
Brandon Rozek 2024-02-16 13:01:59 -05:00
parent 7b7136151b
commit 96efcabd22
No known key found for this signature in database
GPG key ID: 26E457DA82C9F480
2 changed files with 24 additions and 0 deletions

View file

@ -18,6 +18,7 @@
{{ partial "date.html" . }}
{{ partial "reading_time.html" . }}
{{ partial "tags/page.html" . }}
{{ partial "age_warning.html" . }}
<!-- content -->
<div class="e-content">
{{ .Content }}

View file

@ -0,0 +1,23 @@
{{ if and (not .Date.IsZero) .Site.Params.warnPostOlderThanXYears }}
{{ $ageYears := div (sub now.Unix .Date.Unix) 31536000 }}
{{ if .Lastmod }}
{{ $ageYears := div (sub now.Unix .Lastmod.Unix) 31536000 }}
{{ end }}
{{ if gt $ageYears .Site.Params.warnPostOlderThanXYears }}
<div style="margin-top: 1rem; border: 1px solid black; padding: 1rem;">
<em>Warning</em>: This post has not been modified
for over {{ .Site.Params.warnPostOlderThanXYears }} years. For technical posts,
make sure that it is still relevant.
</div>
{{ end }}
{{ end }}