picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.81k stars 616 forks source link

Pico doesn't obey sort order given in meta #660

Closed useronkel closed 1 year ago

useronkel commented 1 year ago

Hi! (nearly forget): config.yml: pages_order_by_meta: sortorder pages_order_by: meta pages_order: asc

First issue, perhaps I'm doing something wrong, but lets say following structure given inside content/

├── Ab, sortorder: 3
│   ├── cx
│   │   ├── index.md
│   │   └── engine.md
│   ├── cex
│   └── index.md
├── Ge, sortorder: 2
│   ├── cxx
│   │   ├── index.md
│   │   └── engine.md
│   ├── cex
│   └── index.md
├── index.md, sortorder: 1
├── Pi, sortorder: 4
│   └── index.md
├── Pr1, sortorder: 6
│   └── index.md
├── Pr2, sortorder: 7
│   └── index.md
└── Rf, sortorder: 5
    └── index.md

In every index.md is meta section with a tag called sortorder

sortorder: 1..n

When I'm using twig to template out the structure with

{% for page in pages(depthOffset=-1) if page.title and not page.hidden %}
{% if page.id == current_page.id %}
               <li class="active"><a href="{{ page.url }}"></a></li>
{% else %}
               <li><a href="{{ page.url }}">{{ page.title }}</a></li>
{% endif %}
{% endfor %}

the result is (only first pages, the sub pages doesn't matter at the moment):

├── Ab
├── Ge
├── Pi
├── Rf
├── Pr1
├── Pr2

Expected is:

├── Ge
├── Ab
├── Pi
├── Rf
├── Pr1
├── Pr2

So, only the first entry is not sort, all others are correctly sorted. Why? :-)

useronkel commented 1 year ago

Found a solution by using search function and closed issues :-)

digitalinferno commented 1 year ago

@useronkel link the solution for reference