picosh / pico

hacker labs - open source and managed web services leveraging SSH
https://pico.sh
MIT License
757 stars 26 forks source link

Consistent ordering of nav items #40

Closed hoelter closed 10 months ago

hoelter commented 10 months ago

I noticed that on a page refresh, nav items would sometimes reorder themselves. I isolated this down to a difference in behavior based on how the nav items were declared in the yaml files.

When the header nav yaml items are prefixed with "-", the toLinks function recieves an array of maps that preserves ordering.

When the yaml nav items aren't prefixed with "-", the toLinks function recieves only a map of the items that did not preserve ordering.

I made use of a different function in the "meta" package that gets all yaml data in a way that preserves ordering and updated the existing code accordingly so that ordering will now be preserved in both cases. I don't have much golang experience, so if I did anything idiomatically incorrect please let me know!