sortOrder fails on page name arrays and section order is case sensitive
Closed this issue · 4 comments
Now that I've got pages generated (thank you!), I am fine tuning my page order and section order within pages.
The first issue I found was that arrays are not handled in this case:
// sort the pages organisms and templates in that order, but not any of
// their sections
['organisms', 'templates']
Arrays are not handled in utils.generateSortOrder, only strings and objects. I added this at line 53 of utils.js so I could keep moving forward on my project:
if (Array.isArray(value)){
for (var i = 0; i < value.length; i++) {
context.pageOrder.push(utils.normalizeName(value[i]))
}
return;
}
For section ordering within a page, I found this statement on https://github.com/straker/livingcss to be untrue:
Names are case insensitive.
Values within arrays are case insensitive, but if you use the object syntax the page name key is case sensitive.
For my page "Colors", the sections will not be sorted with this configuration:
{colors:["greys","oranges","blues","reds","yellows"]}
but the following configuration will sort the sections
{Colors:["greys","oranges","blues","reds","yellows"]}
That's because this test is case sensitive (line 66 after I added the above array code):
if (context.pages[prop])
The key is "Colors", not "colors", so the test is never true.
This is not high priority request as I can work around both issues with context.sortOrder configuration changes.
I'll take a look at this tonight
Thank you! But like I said, there are easy work-arounds for the issues I found, so this is not a high priority at all.
Does this branch fix your issue?
It does! I tested with all lower case, and a mix of objects and arrays, and everything came out as expected and with no errors. Thanks for fixing this so quickly.