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 41292fbca..8a5fcdb91 100644 --- a/src/_includes/partials/collectionsMain.njk +++ b/src/_includes/partials/collectionsMain.njk @@ -1,17 +1,26 @@ -
-
- {% 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/_includes/partials/postslist.njk b/src/_includes/partials/postslist.njk new file mode 100644 index 000000000..9e0b816fa --- /dev/null +++ b/src/_includes/partials/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/tags-en.njk b/src/tags-en.njk new file mode 100644 index 000000000..9d2f6d35f --- /dev/null +++ b/src/tags-en.njk @@ -0,0 +1,21 @@ +--- +pagination: + data: collections + size: 1 + alias: tag + filter: + - all + - nav + - post + - posts +permalink: /en/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] | 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" %}