-
I'm trying to do what's described at #898, sorting by an ---
title: My awesome post
order: 1
---
Content It seems to do that a custom function must created, and then that should be passed to I have this in my function sortByOrder(values) {
let vals = [...values];
return vals.sort((a, b) => Math.sign(a.data.order - b.data.order));
}
eleventyConfig.addFilter('sortByOrder', sortByOrder); but then in my liquid template, doing: {%- for post in collections.oikos sortByOrder -%} results in: I'm using 0.12.1, and sadly spending hours trying to sort :( |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
@ahillio I think you're missing a {%- for post in collections.oikos | sortByOrder -%}
{{ post.data.title }} ({{ post.data.order }})
{% endfor %} |
Beta Was this translation helpful? Give feedback.
@ahillio I think you're missing a
|
before thesortByOrder
filter.This worked for me (using Nunjucks template engine):