lumeland / theme-simple-wiki

Lume theme to create a wiki to store your notes
https://lumeland.github.io/theme-simple-wiki/
MIT License
16 stars 4 forks source link

How to set custom menu item order? #8

Closed thdoan closed 2 months ago

thdoan commented 3 months ago

I saw this code:

menu.vto

  <ul class="menu">
  {{ for item of nav.menu().children?.sort((a, b) => a.data?.order - b.data?.order) }}
    <li>
      {{ include "templates/menu_item.vto" { item } }}
    </li>
  {{ /for }}
  </ul>

However, when I tried to set the order, it didn't work as expected.

aaa.md

---
order: 2
---

bbb.md

---
order: 1
---

aaa.md is still being displayed first despite setting the order to 2. What am I doing wrong?

oscarotero commented 3 months ago

There's a bug in the nav.menu() function that will be fixed in the next version of Lume, and will allow to pass the order in the third argument:

nav.menu("/", "", "order=asc")
oscarotero commented 2 months ago

The order of the pages in the lateral menu works now as expected. Pages are sorted by order variable first and filename second.