Open Wolfr opened 3 years ago
Are you talking about something like?
let categories = ['basics', 'components', 'objects', 'dev-notes']
function sortByCategories(array, data) {
let sortedCategories = []
array.forEach((value) => {
data.forEach((category) => {
if (value === category["category"]) {
sortedCategories.push(category)
}
})
})
return sortedCategories;
}
Yes! Currently the data is here but is also ran through a reduce function to get the categories out of it (by grouping them).
https://github.com/Wolfr/sveltekit-jui/blob/main/src/routes/styleguide/$layout.svelte#L21-L187
Yes! Currently the data is here but is also ran through a reduce function to get the categories out of it (by grouping them).
https://github.com/Wolfr/sveltekit-jui/blob/main/src/routes/styleguide/$layout.svelte#L21-L187
Nice, we could just run the sortByCategories after the reduce and it should be fine. This is what it looks like with the above example ran.
I am sorry but I can't seem to connect the two functions to return the right data, is this something you can PR? 🙏
Sure.
I would like to be able to set the order of categories in an array, and for that order to be used in the styleguide.