Your sites Log in Sign up Menu

Reverse the order of entries?

Is it possible to list {{#allEntries}} in reverse order—oldest at the top; newest at the bottom?


a year ago, 1 replies   developers   Improve this question

Not right now, eventually I plan to add the tags required to list entries in reverse order. However, you can solve this using CSS or JS by reversing the order of the DOM nodes containing the entry links, e.g.

<div id="reverse">
{{#allEntries}}
  <a href="{{{url}}}">{{title}}</a><br>
{{/allEntries}}
</div>

<script type="text/javascript">
var parent = document.getElementById('reverse');

for (var i = 1; i < parent.childNodes.length; i++){
  var child = parent.childNodes[i];
  parent.insertBefore(child, parent.firstChild);
}
</script>

There are also CSS-only strategies using Flexbox, e.g.

#reverse {
  display:flex;
  flex-direction: column-reverse;
}
Answered a year ago ยท Improve this answer

Privacy Terms