Skip to content

Commit 84e81af

Browse files
committed
Adding MG_WEBSITE_AGE
1 parent 451a4f4 commit 84e81af

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ Set this to `True`, if you do not want to display the last article in full on th
162162
**MG_FILTER_TAGS** and **MG_LANG_FILTER_TAGS**
163163
Define those variables as list of tag names if you want to enable the tag filtering buttons.
164164

165+
**MG_WEBSITE_AGE**
166+
If this variable is set, as well as a `now` global variable, then the website age will be added below the description on the index page:
167+
```python
168+
MG_WEBSITE_AGE = 'This blog has %d years.'
169+
JINJA_GLOBALS = { 'now': datetime.now(tz=timezone(TIMEZONE)) }
170+
```
171+
165172
**EXTRA_ATOM_FEED**
166173
An extra URL providing an Atom feed of updates that you want inserted along the blog Atom feed.
167174

templates/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
{% if DESCRIPTION %}
2525
<div class="uk-panel-box mg-description">
2626
{{ DESCRIPTION }}
27+
{% if MG_WEBSITE_AGE and now %}
28+
<br>
29+
{% set years = (now - dates[-1].date) | attr("days") // 365.25 | int %}
30+
{{ MG_WEBSITE_AGE | format(years) }}
31+
{% endif %}
2732
</div>
2833
{% endif %}
2934
{% endblock %}

0 commit comments

Comments
 (0)