File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -86,3 +86,10 @@ export const AST_NODE_TYPES = {
8686 EXPRESSION_STATEMENT : 'ExpressionStatement' ,
8787 } ,
8888} ;
89+
90+ // These positions are explicity before anything else
91+ export const OVERRIDDEN_POSITIONS = [
92+ 'index' , // https://github.com/nodejs/node/blob/main/doc/api/index.md
93+ 'synopsis' , // https://github.com/nodejs/node/blob/main/doc/api/synopsis.md
94+ 'documentation' , // https://github.com/nodejs/node/blob/main/doc/api/documentation.md
95+ ] ;
Original file line number Diff line number Diff line change 1+ import { OVERRIDDEN_POSITIONS } from './constants.mjs' ;
12import buildContent from './utils/buildContent.mjs' ;
23import {
34 getCompatibleVersions ,
@@ -34,7 +35,19 @@ export default {
3435 // Get sorted primary heading nodes
3536 const headNodes = entries
3637 . filter ( node => node . heading . depth === 1 )
37- . sort ( ( a , b ) => a . heading . data . name . localeCompare ( b . heading . data . name ) ) ;
38+ . sort ( ( a , b ) => {
39+ const ai = OVERRIDDEN_POSITIONS . indexOf ( a . api ) ,
40+ bi = OVERRIDDEN_POSITIONS . indexOf ( b . api ) ;
41+ // If this is in OVERRIDDEN_POSITIONS, it must come first
42+ return ai !== - 1 && bi !== - 1
43+ ? ai - bi
44+ : ai !== - 1
45+ ? - 1
46+ : bi !== - 1
47+ ? 1
48+ : // Just compare headings
49+ a . heading . data . name . localeCompare ( b . heading . data . name ) ;
50+ } ) ;
3851
3952 // Generate table of contents
4053 const docPages = headNodes . map ( node => [
You can’t perform that action at this time.
0 commit comments