Skip to content

Commit 9cbf3c5

Browse files
committed
Add block about old blog posts to article, configurable in months
1 parent c1b8edc commit 9cbf3c5

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

_config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ collections:
3737
output: true
3838
permalink: /:collection/:year-:month-:day-:title
3939

40+
expiry_months: 12
41+
4042
feed:
4143
path: atom.xml
4244
collections:

_layouts/article.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@
66
{%- include nav.html -%}
77

88
<main id="main">
9+
10+
{% if page.collection == "posts" %}
11+
{% assign page_ts = page.date | date: '%s' %}
12+
{% assign site_ts = site.time | date: '%s' %}
13+
{% assign difference = site_ts | minus: page_ts %}
14+
{% assign expiry_ts = site.expiry_months | times: 2628000 %}
15+
{% if difference > expiry_ts %}
16+
17+
<blockquote>
18+
This post is more than {{ difference | divided_by: 2628000 }} months old. The
19+
contents may no longer be correct. You should check
20+
<a href="/news">newer posts</a> or refer to our
21+
<a href="/guides">guides section</a> to verify details.
22+
</blockquote>
23+
24+
{% endif %}
25+
{% endif %}
26+
927
{%- include article.html article=page -%}
1028
</main>
1129

0 commit comments

Comments
 (0)