ux-at-icfnext / dmx-library

0 stars 0 forks source link

alpha sort for side menu #4

Open dara-icf opened 1 week ago

dara-icf commented 1 week ago

11ty doesn't have sort out-of the box (aside from create date -- and reverse create date)

we tried a few code blocks in the config file including

eleventyConfig.addCollection("patterns", function (collectionApi) { return collectionApi.getAll().sort(function (a, b) { //return a.date - b.date; // sort by date - ascending return a.title - b.title; // sort by date - descending //return a.inputPath.localeCompare(b.inputPath); // sort by path - ascending //return b.inputPath.localeCompare(a.inputPath); // sort by path - descending }); }); and

eleventyConfig.addCollection("patterns", collection => collection .getAll() .filter(function(item) { return "patterns" in item.data; }) .sort((a, b) => { return (a.data.patterns.title - b.data.patterns.title); }) );

dara-icf commented 1 week ago

A hackey way to do this is to just date: the files in YAML.

Not sustainable -- but since components are slow to come out of USWDS... maybe this works 🤷🏽‍♀️