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">
|
<div class="card">
|
||||||
<h2>Pages sœurs</h2>
|
<h2>Pages sœurs</h2>
|
||||||
<ol>
|
<ol>
|
||||||
{%- for post in collections.all | sort(false, true, "data.eleventySubNavigation.order") -%}
|
{%- for post in collections.all | getSubPages(eleventySubNavigation.parent) -%}
|
||||||
{%- if post.data.eleventySubNavigation.parent == eleventySubNavigation.parent -%}
|
<li><a href="{{ post.url }}">{{ post.data.eleventySubNavigation.key }}</a></li>
|
||||||
<li><a href="{{ post.url }}">{{ post.data.eleventySubNavigation.key }}</a></li>
|
|
||||||
{%- endif -%}
|
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -15,10 +15,8 @@ layout: layouts/parent.njk
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h2>Sous-pages</h2>
|
<h2>Sous-pages</h2>
|
||||||
<ol>
|
<ol>
|
||||||
{%- for post in collections.all | sort(false, true, "data.eleventySubNavigation.order") -%}
|
{%- for post in collections.all | getSubPages(eleventyNavigation.key) -%}
|
||||||
{%- if post.data.eleventySubNavigation.parent == eleventyNavigation.key -%}
|
<li><a href="{{ post.url }}">{{ post.data.eleventySubNavigation.key }}</a></li>
|
||||||
<li><a href="{{ post.url }}">{{ post.data.eleventySubNavigation.key }}</a></li>
|
|
||||||
{%- endif -%}
|
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -15,10 +15,8 @@ Le but de cette page est de montrer comment différents lieux ont évolués entr
|
||||||
## Sous-pages
|
## Sous-pages
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{%- for post in collections.all | sort(false, true, "data.eleventySubNavigation.order") -%}
|
{%- for post in collections.all | getSubPages(eleventyNavigation.key) -%}
|
||||||
{%- if post.data.eleventySubNavigation.parent == eleventyNavigation.key -%}
|
<li><a href="{{ post.url }}">{{ post.data.eleventySubNavigation.key }}</a></li>
|
||||||
<li><a href="{{ post.url }}">{{ post.data.eleventySubNavigation.key }}</a></li>
|
|
||||||
{%- endif -%}
|
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,18 @@ module.exports = function(eleventyConfig) {
|
||||||
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd');
|
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.
|
// Get the first `n` elements of a collection.
|
||||||
eleventyConfig.addFilter("head", (array, n) => {
|
eleventyConfig.addFilter("head", (array, n) => {
|
||||||
if(!Array.isArray(array) || array.length === 0) {
|
if(!Array.isArray(array) || array.length === 0) {
|
||||||
|
|
Loading…
Reference in a new issue