From 652d329c1c6427253ae25dc72aa670d8bd8d9b51 Mon Sep 17 00:00:00 2001 From: Isabel Date: Thu, 14 Dec 2023 11:18:01 -0500 Subject: [PATCH 1/2] Tag pages are working properly --- src/_includes/components/postslist.njk | 35 ++++++++++++++++++++ src/_includes/partials/collectionsMain.njk | 38 +++++++++++++--------- src/tags.njk | 21 ++++++++++++ 3 files changed, 79 insertions(+), 15 deletions(-) create mode 100644 src/_includes/components/postslist.njk create mode 100644 src/tags.njk diff --git a/src/_includes/components/postslist.njk b/src/_includes/components/postslist.njk new file mode 100644 index 000000000..9e0b816fa --- /dev/null +++ b/src/_includes/components/postslist.njk @@ -0,0 +1,35 @@ +
+ {% for post in postslist | reverse %} + +

+ + {% if post.data.title %} + {{ post.data.title }} + {% else %} + Untitled + {% endif %} + +

+ {% if post.data.summary %} +

+ {{ post.data.summary }} +

+ {% endif %} +

+ +

+ {% if post.data.tags %} +

+ {% for tag in post.data.tags %} + {%- if tag != "post" -%} + {% set tagUrl %}/tags/{{ tag }}/{% endset %} + + {%- endif -%} + {% endfor %} +

+ {% endif %} + + {% endfor %} +
diff --git a/src/_includes/partials/collectionsMain.njk b/src/_includes/partials/collectionsMain.njk index 41292fbca..63560067c 100644 --- a/src/_includes/partials/collectionsMain.njk +++ b/src/_includes/partials/collectionsMain.njk @@ -1,17 +1,25 @@ -
-
- {% for item in collections.main | sort(false, false, 'data.title') | localeMatch(locale) %} -
-

{{ item.data.title }}

-

- {% if item.data.description %} - {{ item.data.description }} - {% else %} - {{ landingPage[locale].descriptionNoneText }} - {% endif %} -

-
- {% endfor %} -
+
+ {% for item in collections.main | sort(false, false, 'data.title') | localeMatch(locale) %} +
+

{{ item.data.title }}

+

+ {% if item.data.description %} + {{ item.data.description }} + {% else %} + {{ landingPage[locale].descriptionNoneText }} + {% endif %} + + + {% if item.data.tags %} +

    + {% for tag in item.data.tags %} +
  • {{ tag }}
  • + {% endfor %} +
+ {% endif %} +

+
+ {% endfor %} +
diff --git a/src/tags.njk b/src/tags.njk new file mode 100644 index 000000000..d15f634d7 --- /dev/null +++ b/src/tags.njk @@ -0,0 +1,21 @@ +--- +pagination: + data: collections + size: 1 + alias: tag + filter: + - all + - nav + - post + - posts +permalink: /tags/{{ tag }}/ +layout: layouts/base.njk +eleventyComputed: + title: "Tagged “{{ tag }}”" + metaDescription: "All posts from the Blog tagged with “{{ tag }}”" +--- + +

Tagged “{{ tag }}”

+ +{% set postslist = collections[tag] %} +{% include "components/postslist.njk" %} \ No newline at end of file From 843a9928fa3bb7ec2eb5f3fa14471c0ead19d447 Mon Sep 17 00:00:00 2001 From: Isabel Date: Thu, 14 Dec 2023 16:12:21 -0500 Subject: [PATCH 2/2] Separated tags by French and English --- .eleventy.js | 8 +++++++ src/_includes/partials/collectionsMain.njk | 7 ++++--- .../{components => partials}/postslist.njk | 0 src/{tags.njk => tags-en.njk} | 6 +++--- src/tags-fr.njk | 21 +++++++++++++++++++ 5 files changed, 36 insertions(+), 6 deletions(-) rename src/_includes/{components => partials}/postslist.njk (100%) rename src/{tags.njk => tags-en.njk} (69%) create mode 100644 src/tags-fr.njk diff --git a/.eleventy.js b/.eleventy.js index ac08c71b4..39d4499ba 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -15,6 +15,14 @@ module.exports = function(eleventyConfig) { markdownIt(markdownItOptions).use(markdownItAnchor).use(markdownItAttrs) ); + eleventyConfig.addFilter("filterByLocale", function(collection, locale) { + return collection.filter(item => { + // Extract the language from the URL to determine the content's language + const pathParts = item.url.split('/'); // Split the URL into parts + return pathParts.includes(locale); // Check if the URL contains the language folder + }); + }); + const slugifyFilter = eleventyConfig.javascriptFunctions.slugify; eleventyConfig.addFilter("stripTagsSlugify", (str) => { diff --git a/src/_includes/partials/collectionsMain.njk b/src/_includes/partials/collectionsMain.njk index 63560067c..8a5fcdb91 100644 --- a/src/_includes/partials/collectionsMain.njk +++ b/src/_includes/partials/collectionsMain.njk @@ -13,9 +13,10 @@ {% if item.data.tags %} {% endif %}

diff --git a/src/_includes/components/postslist.njk b/src/_includes/partials/postslist.njk similarity index 100% rename from src/_includes/components/postslist.njk rename to src/_includes/partials/postslist.njk diff --git a/src/tags.njk b/src/tags-en.njk similarity index 69% rename from src/tags.njk rename to src/tags-en.njk index d15f634d7..9d2f6d35f 100644 --- a/src/tags.njk +++ b/src/tags-en.njk @@ -8,7 +8,7 @@ pagination: - nav - post - posts -permalink: /tags/{{ tag }}/ +permalink: /en/tags/{{ tag }}/ layout: layouts/base.njk eleventyComputed: title: "Tagged “{{ tag }}”" @@ -17,5 +17,5 @@ eleventyComputed:

Tagged “{{ tag }}”

-{% set postslist = collections[tag] %} -{% include "components/postslist.njk" %} \ No newline at end of file +{% set postslist = collections[tag] | filterByLocale('en') %} +{% include "partials/postslist.njk" %} diff --git a/src/tags-fr.njk b/src/tags-fr.njk new file mode 100644 index 000000000..cd7a22a32 --- /dev/null +++ b/src/tags-fr.njk @@ -0,0 +1,21 @@ +--- +pagination: + data: collections + size: 1 + alias: tag + filter: + - all + - nav + - post + - posts +permalink: /fr/tags/{{ tag }}/ +layout: layouts/base.njk +eleventyComputed: + title: "Étiqueté “{{ tag }}”" + metaDescription: "Tous les articles du blog étiquetés avec “{{ tag }}”" +--- + +

Étiqueté “{{ tag }}”

+ +{% set postslist = collections[tag] | filterByLocale('fr') %} +{% include "partials/postslist.njk" %}