fix: correction ordre sous-pages
This commit is contained in:
parent
10e1625d12
commit
e7b1be0d6f
4 changed files with 18 additions and 12 deletions
|
@ -24,10 +24,8 @@ layout: layouts/parent.njk
|
|||
<div class="card">
|
||||
<h2>Pages sœurs</h2>
|
||||
<ol>
|
||||
{%- for post in collections.all | sort(false, true, "data.eleventySubNavigation.order") -%}
|
||||
{%- if post.data.eleventySubNavigation.parent == eleventySubNavigation.parent -%}
|
||||
<li><a href="{{ post.url }}">{{ post.data.eleventySubNavigation.key }}</a></li>
|
||||
{%- endif -%}
|
||||
{%- for post in collections.all | getSubPages(eleventySubNavigation.parent) -%}
|
||||
<li><a href="{{ post.url }}">{{ post.data.eleventySubNavigation.key }}</a></li>
|
||||
{%- endfor -%}
|
||||
</ol>
|
||||
</div>
|
||||
|
|
|
@ -15,10 +15,8 @@ layout: layouts/parent.njk
|
|||
<div class="card">
|
||||
<h2>Sous-pages</h2>
|
||||
<ol>
|
||||
{%- for post in collections.all | sort(false, true, "data.eleventySubNavigation.order") -%}
|
||||
{%- if post.data.eleventySubNavigation.parent == eleventyNavigation.key -%}
|
||||
<li><a href="{{ post.url }}">{{ post.data.eleventySubNavigation.key }}</a></li>
|
||||
{%- endif -%}
|
||||
{%- for post in collections.all | getSubPages(eleventyNavigation.key) -%}
|
||||
<li><a href="{{ post.url }}">{{ post.data.eleventySubNavigation.key }}</a></li>
|
||||
{%- endfor -%}
|
||||
</ol>
|
||||
</div>
|
||||
|
|
|
@ -15,10 +15,8 @@ Le but de cette page est de montrer comment différents lieux ont évolués entr
|
|||
## Sous-pages
|
||||
|
||||
<ul>
|
||||
{%- for post in collections.all | sort(false, true, "data.eleventySubNavigation.order") -%}
|
||||
{%- if post.data.eleventySubNavigation.parent == eleventyNavigation.key -%}
|
||||
<li><a href="{{ post.url }}">{{ post.data.eleventySubNavigation.key }}</a></li>
|
||||
{%- endif -%}
|
||||
{%- for post in collections.all | getSubPages(eleventyNavigation.key) -%}
|
||||
<li><a href="{{ post.url }}">{{ post.data.eleventySubNavigation.key }}</a></li>
|
||||
{%- endfor -%}
|
||||
</ul>
|
||||
|
||||
|
|
|
@ -53,6 +53,18 @@ module.exports = function(eleventyConfig) {
|
|||
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd');
|
||||
});
|
||||
|
||||
eleventyConfig.addFilter("getSubPages", (array, parent) => {
|
||||
if (!Array.isArray(array) || array.length === 0) {
|
||||
return [];
|
||||
}
|
||||
return array
|
||||
.filter(arrayElement => {
|
||||
return arrayElement.data.eleventySubNavigation && arrayElement.data.eleventySubNavigation?.parent === parent
|
||||
}).sort(
|
||||
(a, b) => a.data.eleventySubNavigation.order - b.data.eleventySubNavigation.order
|
||||
);
|
||||
});
|
||||
|
||||
// Get the first `n` elements of a collection.
|
||||
eleventyConfig.addFilter("head", (array, n) => {
|
||||
if(!Array.isArray(array) || array.length === 0) {
|
||||
|
|
Loading…
Reference in a new issue