urbit / tree

The web interface for your urbit.
13 stars 7 forks source link

Markdown YAML order sorting incorrectly. #34

Open xykj61 opened 7 years ago

xykj61 commented 7 years ago

The reason the docs/arvo pages seem out of order (Security Drivers and API's coming before basic Hoon material) is because the YAML sorting is not functioning properly. Tree is sorting 11 and 12 before 2 and 3. I tried fixing this by changing pages 0-9 to 00-09. This didn't work, but changing the page range from 1-12 to 11-22 fixed this.

In general this will likely continue to be pretty annoying for people wanting to, say, host their own blogs or static pages through Tree. Someone who wants to add a new post in the middle of their blog, for example, has to go through and change each of the sort orders manually. It's even more annoying if you're running this on localhost, as saving one file and not the others will overwrite the changes you just made since the ordering doesn't make sense to Tree, i.e. you have to save all of the individual sort changes or this doesn't work.

I could go on. Anyways, where in the Tree code can this be fixed to something better?

galenwp commented 7 years ago

The (possibly) offending function is probably this one: https://github.com/urbit/tree/blob/master/js/utils/util.coffee#L44. Specifically: https://github.com/urbit/tree/blob/master/js/utils/util.coffee#L69.

Basically, if not every child has a sort parameter, then we revert to sorting by name. Otherwise, we use Number(v.meta.sort) as the key. So perhaps the object we produce:

1: 'some value'
11: 'some other value'

Doesn't render correctly once it gets in here: https://github.com/urbit/tree/blob/master/js/components/ListComponent.coffee#L38 ?

xykj61 commented 7 years ago

So, fix the CoffeeScript, or the ES6?

galenwp commented 7 years ago

Fixing the coffeescript is fine. Shouldn't be too difficult to port the fix, and I'd like to deploy a fix.