Skip to content

Instantly share code, notes, and snippets.

View nathnp's full-sized avatar

Nathan nathnp

  • Maryland
  • 23:47 (UTC -04:00)
View GitHub Profile
@nathnp
nathnp / PostAgeWarning.html
Last active July 20, 2024 01:33
Post age warning for Hugo
{{- $PostYear := .Date -}}
{{- $CurrentYear := time.Now -}}
{{- $YearDifU := math.Sub $CurrentYear.Unix $PostYear.Unix -}}
{{- $TPostYear := .Date | time.Format "2006" | int -}}
{{- $YearDif := math.Sub (now.Year | int) $TPostYear -}}
{{- if ge $YearDifU 31536000 -}}
<p class="notice">
This post is over {{ if eq $YearDif 1 }} a year{{- else -}}{{- $YearDif }} years{{- end }} old. The information here may be out of date, and may not reflect my current thoughts or opinions.
</p>
{{- end -}}