From 76773c4ad8dd0a5c4293417395e920a923eeacd6 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 1 Jul 2021 17:53:07 +0100 Subject: [PATCH] Re-add text above old post content --- source/_layouts/post.html.twig | 8 +++++++- source/_partials/post/old-post-message.html.twig | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 source/_partials/post/old-post-message.html.twig diff --git a/source/_layouts/post.html.twig b/source/_layouts/post.html.twig index 62d7651c6..89d166fa0 100644 --- a/source/_layouts/post.html.twig +++ b/source/_layouts/post.html.twig @@ -5,10 +5,16 @@
+
+ {% include 'post/old-post-message' with { + post: page, + } only %} +
+
{{ parent() }}
diff --git a/source/_partials/post/old-post-message.html.twig b/source/_partials/post/old-post-message.html.twig new file mode 100644 index 000000000..76098da53 --- /dev/null +++ b/source/_partials/post/old-post-message.html.twig @@ -0,0 +1,12 @@ +{% macro shouldDisplayOldPostMessage(post) %} + {% set cutOffDate = 'today -1 year'|date('U') %} + {{ post.date <= cutOffDate }} +{% endmacro %} + +{% import _self as helpers %} + +{% if helpers.shouldDisplayOldPostMessage(post)|trim %} +
+

Warning: This post is over a year old. I don't always update old posts with new information, so some of this information may be out of date.

+
+{% endif %}