From 5945f278ae45b5111e2acba3dd7bb5efd612774e Mon Sep 17 00:00:00 2001 From: TheThomaas Date: Sat, 24 Jun 2023 13:07:06 +0200 Subject: [PATCH] Add taglist page --- .eleventy.js | 9 ++++++ src/_data/Term.json | 9 ++++++ src/_data/navigation.json | 8 ++++++ src/_includes/partials/article-head.html | 2 +- src/_includes/partials/post-list.html | 4 +-- src/blog.md | 3 +- src/index.md | 1 + src/tags-list.md | 13 +++++++++ src/tags.md | 36 ++++++------------------ 9 files changed, 54 insertions(+), 31 deletions(-) create mode 100644 src/tags-list.md diff --git a/.eleventy.js b/.eleventy.js index 84c27b8..b4fa81d 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -36,6 +36,15 @@ module.exports = config => { return [...collection.getFilteredByGlob('./src/posts/*.md')].reverse(); }); + // Return all the tags used in a collection + config.addFilter("getAllTags", collection => { + let tagSet = new Set(); + for(let item of collection) { + (item.data.tags || []).forEach(tag => tagSet.add(tag)); + } + return Array.from(tagSet); + }); + return { markdownTemplateEngine: 'njk', dataTemplateEngine: 'njk', diff --git a/src/_data/Term.json b/src/_data/Term.json index 91e67d3..a46e36c 100644 --- a/src/_data/Term.json +++ b/src/_data/Term.json @@ -3,6 +3,15 @@ "SkipLink": "Skip to content", "ToggleTheme": "Toggle theme", "TopLink": "Back to top", + "Listing": { + "Tags": { + "Title": "Tagged", + "More": { + "See": "See", + "All": "all tags" + } + } + }, "Footer": { "lastDeployment": "Dernier déploiement le", "createdWith": "Built with" diff --git a/src/_data/navigation.json b/src/_data/navigation.json index 174630b..42b930a 100644 --- a/src/_data/navigation.json +++ b/src/_data/navigation.json @@ -7,6 +7,14 @@ { "text": "About", "url": "/about/" + }, + { + "text": "Blog", + "url": "/blog/" + }, + { + "text": "Demo", + "url": "/tags/demo/" } ] } diff --git a/src/_includes/partials/article-head.html b/src/_includes/partials/article-head.html index c2505c5..5140ec7 100644 --- a/src/_includes/partials/article-head.html +++ b/src/_includes/partials/article-head.html @@ -12,7 +12,7 @@ {% if tags %} {% for tag in tags %}
  • - {{ tag | title }} + {{ tag | title }}
  • {% endfor %} {% endif %} diff --git a/src/_includes/partials/post-list.html b/src/_includes/partials/post-list.html index 9129196..b333500 100644 --- a/src/_includes/partials/post-list.html +++ b/src/_includes/partials/post-list.html @@ -1,6 +1,6 @@
      - {%- asyncEach blog in collections.blog -%} + {%- asyncEach blog in postslist -%}
    1. {{ blog.data.title }}

        @@ -8,7 +8,7 @@ {%- if blog.data.tags -%} {%- for tag in blog.data.tags -%}
      • - {{ tag | title }} + {{ tag | title }}
      • {%- endfor -%} {%- endif -%} diff --git a/src/blog.md b/src/blog.md index 1c40e94..69a92b5 100644 --- a/src/blog.md +++ b/src/blog.md @@ -2,9 +2,10 @@ title: 'Blog' layout: 'list' --- -# Blog +# {{ title }} The latest articles from around the studio, demonstrating our design thinking, strategy and expertise. +{% set postslist = collections.blog %} {% include "partials/post-list.html" %} \ No newline at end of file diff --git a/src/index.md b/src/index.md index b793629..3f08635 100644 --- a/src/index.md +++ b/src/index.md @@ -7,4 +7,5 @@ metaDesc: 'A made up agency site that you build if you take Learn Eleventy From layout: 'home' --- +{% set postslist = collections.blog %} {% include "partials/post-list.html" %} \ No newline at end of file diff --git a/src/tags-list.md b/src/tags-list.md new file mode 100644 index 0000000..de5a07d --- /dev/null +++ b/src/tags-list.md @@ -0,0 +1,13 @@ +--- +title: Tags +permalink: /tags/ +layout: list +--- +

        {{ title }}

        + +
          +{% for tag in collections.all | getAllTags %} + {% set tagUrl %}/tags/{{ tag | slugify }}/{% endset %} +
        • +{% endfor %} +
        \ No newline at end of file diff --git a/src/tags.md b/src/tags.md index 9d17f8c..b6f971e 100644 --- a/src/tags.md +++ b/src/tags.md @@ -1,35 +1,17 @@ --- -title: 'Tag Archive' -layout: 'list' +eleventyComputed: + title: "{{ Term.Site.Listing.Tags.Title }} “{{ tag }}”" +permalink: '/tags/{{ tag | slug }}/' pagination: data: collections size: 1 alias: tag -permalink: '/tag/{{ tag | slug }}/' +layout: 'list' --- -

        Tagged “{{ tag }}”

        +

        {{ Term.Site.Listing.Tags.Title }} “{{ tag }}”

        -
        -
          - {% set taglist = collections[ tag ] %} - {% for blog in taglist | reverse %} -
        1. -

          {{ blog.data.title }}

          -
            -
          • - {%- if blog.data.tags -%} - {%- for tag in blog.data.tags -%} -
          • - {{ tag | title }} -
          • - {%- endfor -%} - {%- endif -%} -
          - {%- if blog.data.leading -%} -

          {{ blog.data.leading }}

          - {%- endif -%} -
        2. - {%- endfor -%} -
        -
        \ No newline at end of file +{% set postslist = collections[ tag ] %} +{% include "partials/post-list.html" %} + +

        {{ Term.Site.Listing.Tags.More.See }} {{ Term.Site.Listing.Tags.More.All }}.

        \ No newline at end of file