Browse Source

Ordentlich formatierte Datumswerte

master
Christian Aust 1 month ago
parent
commit
c1a0e83e86
  1. 6
      _layouts/post.html
  2. 16
      _plugins/i18n.rb
  3. 4
      index.html

6
_layouts/post.html

@ -5,9 +5,9 @@ layout: default
<div class="post">
<h1 class="post-title">{{ page.title }}</h1>
<p class="post-date">
<time datetime="{{ page.date | date_to_xmlschema }}" >{{ page.date | date_to_string }}</time>
<time datetime="{{ page.date | date_to_xmlschema }}" >{{ page.date | date_to_local }}</time>
{% if page.update %}
| <time datetime="{{ page.update | date_to_xmlschema }}">Aktualisiert am {{ page.update | date_to_string }}</time>
| <time datetime="{{ page.update | date_to_xmlschema }}">Aktualisiert am {{ page.update | date_to_local }}</time>
{% endif %}
{% if page.category %}
@ -34,7 +34,7 @@ layout: default
<li>
<a href="{{ site.baseurl }}{{ post.url }}">
{{ post.title }}
<small>{{ post.date | date_to_string }}</small>
<small>{{ post.date | date_to_local }}</small>
</a>
</li>
{% endfor %}

16
_plugins/i18n.rb

@ -0,0 +1,16 @@
require 'date'
module Jekyll
module I18n
MONTHS = %w[Januar Februar März April Mai Juni Juli August September Oktober November Dezember]
def date_to_local(input)
if input.is_a?(String)
input = DateTime.parse(input).to_time
end
input.strftime "%-d. #{MONTHS[input.month-1]} %Y"
end
end
end
Liquid::Template.register_filter(Jekyll::I18n)

4
index.html

@ -16,9 +16,9 @@ sitemap:
</h1>
<p class="post-date">
<time datetime="{{ post.date | date_to_xmlschema }}" >{{ post.date | date_to_string }}</time>
<time datetime="{{ post.date | date_to_xmlschema }}" >{{ post.date | date_to_local }}</time>
{% if post.update %}
| <time datetime="{{ post.update | date_to_xmlschema }}">Aktualisiert am {{ post.update | date_to_string }}</time>
| <time datetime="{{ post.update | date_to_xmlschema }}">Aktualisiert am {{ post.update | date_to_local }}</time>
{% endif %}
{% if post.category %}
{% assign topic = site.topics | where: "title", post.category | first %}

Loading…
Cancel
Save