From 5aeac7db7a0dafacc4619da67d8fb441d12963d5 Mon Sep 17 00:00:00 2001 From: John Bowdre Date: Sun, 6 Mar 2022 15:24:00 -0600 Subject: [PATCH] display a notice on posts which haven't been updated in more than a year --- i18n/en.toml | 5 ++++- layouts/_default/single.html | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/i18n/en.toml b/i18n/en.toml index 704fa79..958a9c1 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -32,4 +32,7 @@ other = "Search Results" other = "Query is too short" [type_to_search] -other = "Type to search" \ No newline at end of file +other = "Type to search" + +[old_content] +other = "What you're about to read hasn't been updated in more than a year. The information may be out of date. Drop a comment below if you find something that needs updating." \ No newline at end of file diff --git a/layouts/_default/single.html b/layouts/_default/single.html index e174b3f..795cb95 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,6 +1,7 @@ {{- define "main" }} {{- $s := .Site.Params }} {{- $p := .Params }} +{{- $ageDays := div (sub now.Unix .Date.Unix) 86400 }} {{- $scratch := newScratch }} {{- if isset $p "image" }} {{- $scratch.Set "image" $p.image }} @@ -14,6 +15,14 @@ {{- $t := .Title }}

{{ $t }}

{{- partial "post-meta" . }} + {{ with .Param "lastmod" }} + {{ $ageDays = div (sub now.Unix .Unix) 86400 }} + {{ end }} + {{ if gt $ageDays 365 }} +
Technology keeps moving but this post has not.
+ {{ T "old_content" }} +
+ {{ end }} {{- partial "image-feature" . }} {{ if and (gt .WordCount 400 ) (gt (len .TableOfContents) 180) ($s.toc) }}