Skip to content

Commit

Permalink
Year number behind articles
Browse files Browse the repository at this point in the history
Issue: #52
  • Loading branch information
SSirjes committed Apr 17, 2017
1 parent e3f3dcf commit 672171f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions components/blog-article-variables.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% capture dont_render %}
{% assign current_year = "now" | date: "%Y" | to_num %}
{% endcapture %}
10 changes: 9 additions & 1 deletion components/post-box.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<article class="post">
<header class="post-header">
<h2 class="post-title">{% if post-box == "article" %}{% editable article.title %}{% else %}<a href="{{ article.url }}">{{ article.title }}</a>{% endif %}</h2>
<time class="post-date" datetime="{{ article.created_at | date : "%Y-%m-%d" }}">{{ article.created_at | format_date : "long" }}</time>
{% assign article_year = article.created_at | format_date: "%Y" | to_num %}

{% if article_year == current_year %}
{% assign article_date_format = "long_without_year" %}
{% else %}
{% assign article_date_format = "long" %}
{% endif %}

<time class="post-date" datetime="{{ article.created_at | date: '%Y-%m-%d' }}">{{ article.created_at | format_date: article_date_format }}</time>
<div class="post-author">{{ article.author.name }}</div>
</header>

Expand Down
1 change: 1 addition & 0 deletions layouts/blog___news.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!DOCTYPE html>
{% include "blog-article-variables" %}
<html class="{% if editmode %}editmode{% else %}public{% endif %}" lang="{{ page.language_code }}">
<head prefix="og: http://ogp.me/ns#">
{% include "template-variables" %}
Expand Down
1 change: 1 addition & 0 deletions layouts/blog_article.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!DOCTYPE html>
{% include "blog-article-variables" %}
<html class="{% if editmode %}editmode{% else %}public{% endif %}" lang="{{ page.language_code }}">
<head prefix="og: http://ogp.me/ns#">
{% assign blog_article_page = true %}
Expand Down
7 changes: 7 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@
"file": "components/topbar.tpl",
"layout_name": "topbar",
"title": "topbar"
},
{
"title": "blog-article-variables",
"layout_name": "blog-article-variables",
"content_type": "component",
"component": true,
"file": "components/blog-article-variables.tpl"
}
],
"assets": [
Expand Down

0 comments on commit 672171f

Please sign in to comment.