Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
39 changes: 24 additions & 15 deletions src/_includes/partials/collectionsMain.njk
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@

<div class="container">
<div class="row wb-eqht mrgn-tp-lg gc-srvinfo">
{% for item in collections.main | sort(false, false, 'data.title') | localeMatch(locale) %}
<div class="col-md-6">
<h3><a href="{{ item.url }}">{{ item.data.title }}</a></h3>
<p>
{% if item.data.description %}
{{ item.data.description }}
{% else %}
{{ landingPage[locale].descriptionNoneText }}
{% endif %}
</p>
</div>
{% endfor %}
</div>
<div class="row wb-eqht mrgn-tp-lg gc-srvinfo">
{% for item in collections.main | sort(false, false, 'data.title') | localeMatch(locale) %}
<div class="col-md-6">
<h3><a href="{{ item.url }}">{{ item.data.title }}</a></h3>
<p>
{% if item.data.description %}
{{ item.data.description }}
{% else %}
{{ landingPage[locale].descriptionNoneText }}
{% endif %}

<!-- Display tags if available -->
{% if item.data.tags %}
<ul>
{% for tag in item.data.tags %}
<li><a href="/{{ locale }}/tags/{{ tag | slug }}/index.html">{{ tag }}</a></li>
{% endfor %}

</ul>
{% endif %}
</p>
</div>
{% endfor %}
</div>
</div>
35 changes: 35 additions & 0 deletions src/_includes/partials/postslist.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<section>
{% for post in postslist | reverse %}
<article{% if post.url == url %} data-current="current item"{% endif %}>
<h3>
<a href="{{ post.url | url }}">
{% if post.data.title %}
{{ post.data.title }}
{% else %}
Untitled
{% endif %}
</a>
</h3>
{% if post.data.summary %}
<p>
{{ post.data.summary }}
</p>
{% endif %}
<p>
<time datetime="{{ post.date | postDate }}">
<small>{{ post.date | postDate }}</small>
</time>
</p>
{% if post.data.tags %}
<p>
{% for tag in post.data.tags %}
{%- if tag != "post" -%}
{% set tagUrl %}/tags/{{ tag }}/{% endset %}
<a href="{{ tagUrl | url }}" rel="tag">{{ tag }}</a>
{%- endif -%}
{% endfor %}
</p>
{% endif %}
</article>
{% endfor %}
</section>
21 changes: 21 additions & 0 deletions src/tags-en.njk
Original file line number Diff line number Diff line change
@@ -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 }}”"
---

<h1>Tagged “{{ tag }}”</h1>

{% set postslist = collections[tag] | filterByLocale('en') %}
{% include "partials/postslist.njk" %}
21 changes: 21 additions & 0 deletions src/tags-fr.njk
Original file line number Diff line number Diff line change
@@ -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 }}”"
---

<h1>Étiqueté “{{ tag }}”</h1>

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