Skip to content

Commit 1f901e6

Browse files
authored
Merge pull request #161 from kevanstannard/sort-index-headers
Sort index headers
2 parents 7734428 + 10fb468 commit 1f901e6

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

scripts/extract-indices.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,23 @@ const createIndex = result => {
9292
// NextJS router
9393
return result.reduce((acc, data) => {
9494
const { signatures = [], moduleName, headers } = data;
95+
96+
// Sort the headers, but keep type `t` as the first header.
97+
const headersSorted = [...headers].sort(
98+
(headerA, headerB) => {
99+
if (headerA.name === 't') {
100+
return -1
101+
} else if (headerB.name === 't') {
102+
return 1
103+
} else {
104+
return headerA.name.localeCompare(headerB.name)
105+
}
106+
}
107+
);
108+
95109
acc["/" + data.href] = {
96110
moduleName,
97-
headers
111+
headers: headersSorted
98112
};
99113

100114
return acc;

0 commit comments

Comments
 (0)