Skip to content

Commit ab376c5

Browse files
warddomingohui
authored andcommitted
Use date_format if set in configuration (jekyll#70)
Merge pull request 70
1 parent d70002d commit ab376c5

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ The site's default CSS has now moved to a new place within the gem itself, [`ass
4646

4747
--
4848

49+
### Change default date format
50+
51+
You can change the default date format by specifying `site.minima.date_format`
52+
in `_config.yml`.
53+
54+
```
55+
# Minima date format
56+
# refer to http://shopify.github.io/liquid/filters/date/ if you want to customize this
57+
minima:
58+
date_format: "%b %-d, %Y"
59+
```
60+
61+
--
62+
4963
### Enabling comments (via Disqus)
5064
5165
Optionally, if you have a Disqus account, you can tell Jekyll to use it to show a comments section below each post.

_layouts/home.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ <h1 class="page-heading">Posts</h1>
1111
<ul class="post-list">
1212
{% for post in site.posts %}
1313
<li>
14-
<span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</span>
14+
{% assign date_format = site.minima.date_format | default: "%b %-d, %Y" %}
15+
<span class="post-meta">{{ post.date | date: date_format }}</span>
1516

1617
<h2>
1718
<a class="post-link" href="{{ post.url | relative_url }}">{{ post.title | escape }}</a>

_layouts/post.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55

66
<header class="post-header">
77
<h1 class="post-title" itemprop="name headline">{{ page.title | escape }}</h1>
8-
<p class="post-meta"><time datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">{{ page.date | date: "%b %-d, %Y" }}</time>{% if page.author %} • <span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">{{ page.author }}</span></span>{% endif %}</p>
8+
<p class="post-meta">
9+
<time datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">
10+
{% assign date_format = site.minima.date_format | default: "%b %-d, %Y" %}
11+
{{ page.date | date: date_format }}
12+
</time>
13+
{% if page.author %}
14+
<span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">{{ page.author }}</span></span>
15+
{% endif %}</p>
916
</header>
1017

1118
<div class="post-content" itemprop="articleBody">

example/_config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ stackoverflow_username: stackoverflow
1919
youtube_username: youtube
2020
googleplus_username: google+
2121

22+
# Minima date format
23+
# refer to http://shopify.github.io/liquid/filters/date/ if you want to customize this
24+
minima:
25+
date_format: "%b %-d, %Y"
26+
2227
# If you want to link only specific pages in your header, uncomment
2328
# this and add the path to the pages in order as they should show up
2429
#header_pages:

0 commit comments

Comments
 (0)