diff --git a/.eleventy.js b/.eleventy.js index 0cf4bca..4cb6849 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -41,17 +41,16 @@ module.exports = function(eleventyConfig) { return Math.min.apply(null, numbers); }); + eleventyConfig.addFilter("filterTagList", tags => { + // should match the list in tags.njk + return (tags || []).filter(tag => ["all", "nav", "post", "posts"].indexOf(tag) === -1); + }) + // Create an array of all tags eleventyConfig.addCollection("tagList", function(collection) { let tagSet = new Set(); - collection.getAll().forEach(function(item) { - if( "tags" in item.data ) { - let tags = item.data.tags; - - // this list should match the `filter` list in tags.njk - tags.filter(tag => ["all", "nav", "post", "posts"].indexOf(tag) === -1) - .forEach(tag => tagSet.add(tag)); - } + collection.getAll().forEach(item => { + (item.data.tags || []).forEach(tag => tagSet.add(tag)); }); return [...tagSet]; diff --git a/_includes/layouts/post.njk b/_includes/layouts/post.njk index 83eae7a..f38bd48 100644 --- a/_includes/layouts/post.njk +++ b/_includes/layouts/post.njk @@ -4,14 +4,21 @@ templateClass: tmpl-post ---

{{ title }}

+ + +{%- for tag in tags | filterTagList %} +{%- set tagUrl %}/tags/{{ tag | slug }}/{% endset %} +{{ tag }} +{%- endfor %} + {{ content | safe }} {%- set nextPost = collections.posts | getNextCollectionItem(page) %} {%- set previousPost = collections.posts | getPreviousCollectionItem(page) %} -{% if nextPost or previousPost %} +{%- if nextPost or previousPost %}
-{% endif %} +{%- endif %} diff --git a/_includes/postslist.njk b/_includes/postslist.njk index d4896ac..d220513 100644 --- a/_includes/postslist.njk +++ b/_includes/postslist.njk @@ -3,11 +3,9 @@
  • {% if post.data.title %}{{ post.data.title }}{% else %}{{ post.url }}{% endif %} - {% for tag in post.data.tags %} - {%- if collections.tagList.indexOf(tag) != -1 -%} - {% set tagUrl %}/tags/{{ tag }}/{% endset %} + {% for tag in post.data.tags | filterTagList %} + {% set tagUrl %}/tags/{{ tag | slug }}/{% endset %} {{ tag }} - {%- endif -%} {% endfor %}
  • {% endfor %} diff --git a/posts/firstpost.md b/posts/firstpost.md index 0fc8a78..21b3d6c 100644 --- a/posts/firstpost.md +++ b/posts/firstpost.md @@ -3,7 +3,7 @@ title: This is my first post. description: This is a post on My Blog about agile frameworks. date: 2018-05-01 tags: - - another-tag + - another tag layout: layouts/post.njk --- Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment. diff --git a/posts/fourthpost.md b/posts/fourthpost.md index 4f11fd4..c928a9f 100644 --- a/posts/fourthpost.md +++ b/posts/fourthpost.md @@ -2,7 +2,7 @@ title: This is my fourth post. description: This is a post on My Blog about touchpoints and circling wagons. date: 2018-09-30 -tags: second-tag +tags: second tag layout: layouts/post.njk --- Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment. diff --git a/posts/secondpost.md b/posts/secondpost.md index f9ecade..e2e4ca4 100644 --- a/posts/secondpost.md +++ b/posts/secondpost.md @@ -3,7 +3,7 @@ title: This is my second post. description: This is a post on My Blog about leveraging agile frameworks. date: 2018-07-04 tags: - - number-2 + - number 2 layout: layouts/post.njk --- Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment. diff --git a/posts/thirdpost.md b/posts/thirdpost.md index fb8c056..df0ee74 100644 --- a/posts/thirdpost.md +++ b/posts/thirdpost.md @@ -3,7 +3,7 @@ title: This is my third post. description: This is a post on My Blog about win-win survival strategies. date: 2018-08-24 tags: - - second-tag + - second tag layout: layouts/post.njk --- Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment. diff --git a/tags-list.njk b/tags-list.njk index 028a530..d37ae36 100644 --- a/tags-list.njk +++ b/tags-list.njk @@ -4,7 +4,7 @@ layout: layouts/home.njk ---

    Tags

    -{% for tag in collections.tagList %} - {% set tagUrl %}/tags/{{ tag }}/{% endset %} +{% for tag in collections.tagList | filterTagList %} + {% set tagUrl %}/tags/{{ tag | slug }}/{% endset %} {{ tag }} {% endfor %} diff --git a/tags.njk b/tags.njk index ec7f877..0fbd53b 100644 --- a/tags.njk +++ b/tags.njk @@ -13,7 +13,7 @@ pagination: layout: layouts/home.njk eleventyComputed: title: Tagged “{{ tag }}” -permalink: /tags/{{ tag }}/ +permalink: /tags/{{ tag | slug }}/ ---

    Tagged “{{ tag }}”