Skip to content

Commit 604ddfe

Browse files
authored
fix: new docs section sorting (#9137)
1 parent 540fd38 commit 604ddfe

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/dev/s2-docs/src/Nav.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ export function Nav({pages, currentPage}: PageProps) {
3131

3232
let [maskSize, setMaskSize] = useState(0);
3333

34+
let sortedSections = [...sections].sort((a, b) => {
35+
if (a[0] === 'Getting started') {
36+
return -1;
37+
}
38+
if (b[0] === 'Getting started') {
39+
return 1;
40+
}
41+
return a[0].localeCompare(b[0]);
42+
});
43+
3444
return (
3545
<nav
3646
onScroll={e => setMaskSize(Math.min(e.currentTarget.scrollTop, 32))}
@@ -50,7 +60,7 @@ export function Nav({pages, currentPage}: PageProps) {
5060
lg: 'block'
5161
}
5262
})}>
53-
{[...sections].sort((a, b) => a[0] === 'Getting started' ? -1 : a[0].localeCompare(b[0])).map(([name, pages]) => (
63+
{sortedSections.map(([name, pages]) => (
5464
<SideNavSection title={name} key={name}>
5565
<SideNav>
5666
{pages

0 commit comments

Comments
 (0)