Skip to content

Commit

Permalink
add modified date
Browse files Browse the repository at this point in the history
  • Loading branch information
saschadiercks committed Apr 16, 2019
1 parent bdea79d commit 2f3543f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion .eleventy.js
@@ -1,8 +1,13 @@
const { DateTime } = require('luxon');

module.exports = function(eleventyConfig) {

eleventyConfig.addFilter("readable_date", function(date) {
return DateTime.fromJSDate(date).toFormat('dd LLL yyyy')
});

eleventyConfig.addFilter("get_suffix", function(page) {
const path = page.inputPath.split('.')
//return path[path.length - 2]
return path[path.length - 1]
});

Expand Down
5 changes: 5 additions & 0 deletions src/eleventy/includes/components/library.njk
Expand Up @@ -16,6 +16,8 @@

{# we dont want the desciption.md to be displayed #}
{% if item | get_filename != "description.md" %}
{% set latest_date = item.date %}

{#
we need to OPEN the SECTION here to group the snippets
andd use the parentdrectory as an identifier
Expand All @@ -31,6 +33,9 @@
{# we only want the desciption.md to be displayed #}
{% if item | get_filename == "description.md" %}
{%- include "components/code/description.njk" -%}

<span class="sdi-meta">Last modified: {{ latest_date | readable_date }}</span>

{# we need to CLOSE the SECTION here to group the snippets #}
</section>
{% endif %}
Expand Down
3 changes: 2 additions & 1 deletion src/eleventy/pages/5-objects/5-objects.json
@@ -1,4 +1,5 @@
{
"tags": "objects",
"layout": "objects"
"layout": "objects",
"date": "Last Modified"
}

0 comments on commit 2f3543f

Please sign in to comment.