Skip to content

Commit

Permalink
Migration guides nav: sort alphabetically (part of #8860) (#8896)
Browse files Browse the repository at this point in the history
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
  • Loading branch information
olets and sarah11918 committed Jul 23, 2024
1 parent 998558e commit f1078e8
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions src/components/MigrationGuidesNav.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,9 @@ const lang = getLanguageFromURL(Astro.url.pathname);
const enPages = englishPages.filter(isMigrationEntry);
/** Array of frameworks we have good content for and want to show first in the list. */
const showFirst: string[] = [];
// Reverse the array to make our logic simpler later.
showFirst.reverse();
const links = enPages
.sort((a, b) => {
// Sort frameworks in the `showFirst` array first.
const aPriority = showFirst.indexOf(a.data.framework);
const bPriority = showFirst.indexOf(b.data.framework);
if (aPriority !== -1 || bPriority !== -1) return aPriority > bPriority ? -1 : 1;
// Sort full guides before stubs.
if (a.data.stub && !b.data.stub) return 1;
if (!a.data.stub && b.data.stub) return -1;
// If they’re both stubs, or neither stubs, sort alphabetically.
// Sort alphabetically.
return a.data.framework.toLowerCase() > b.data.framework.toLowerCase() ? 1 : -1;
})
.map((page) => {
Expand Down

0 comments on commit f1078e8

Please sign in to comment.