docs-utils: make reference table of content in alphabetical order (#10084)
This commit is contained in:
1 parent
662b096a46
commit
c054f47872
1 file changed
+36
-24
@@ -30,12 +30,16 @@ export default function (theme: MarkdownTheme) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function pushGroup(group: ReflectionGroup, md: string[]) {
|
function pushGroup(group: ReflectionGroup, md: string[]) {
|
||||||
const children = group.children.map(
|
const children = group.children
|
||||||
(child) =>
|
.sort((childA, childB) => {
|
||||||
`- [${escapeChars(child.name)}](${Handlebars.helpers.relativeURL(
|
return childA.name.localeCompare(childB.name)
|
||||||
child.url
|
})
|
||||||
)})`
|
.map(
|
||||||
)
|
(child) =>
|
||||||
|
`- [${escapeChars(child.name)}](${Handlebars.helpers.relativeURL(
|
||||||
|
child.url
|
||||||
|
)})`
|
||||||
|
)
|
||||||
md.push(children.join("\n"))
|
md.push(children.join("\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,26 +48,34 @@ export default function (theme: MarkdownTheme) {
|
|||||||
md.push(`## Table of contents\n\n`)
|
md.push(`## Table of contents\n\n`)
|
||||||
}
|
}
|
||||||
const headingLevel = hideInPageTOC ? `##` : `###`
|
const headingLevel = hideInPageTOC ? `##` : `###`
|
||||||
this.groups?.forEach((group) => {
|
this.groups
|
||||||
const groupTitle = Object.hasOwn(reflectionGroupRename, group.title)
|
?.sort((groupA, groupB) => {
|
||||||
? reflectionGroupRename[group.title]
|
return groupA.title.localeCompare(groupB.title)
|
||||||
: group.title
|
})
|
||||||
if (group.categories) {
|
.forEach((group) => {
|
||||||
group.categories.forEach((category) => {
|
const groupTitle = Object.hasOwn(reflectionGroupRename, group.title)
|
||||||
md.push(`${headingLevel} ${category.title} ${groupTitle}\n\n`)
|
? reflectionGroupRename[group.title]
|
||||||
pushGroup(category as ReflectionGroup, md)
|
: group.title
|
||||||
md.push("\n")
|
if (group.categories) {
|
||||||
})
|
group.categories
|
||||||
} else {
|
.sort((catA, catB) => {
|
||||||
if (!hideInPageTOC || isVisible) {
|
return catA.title.localeCompare(catB.title)
|
||||||
if (!hideTocHeaders) {
|
})
|
||||||
md.push(`${headingLevel} ${groupTitle}\n\n`)
|
.forEach((category) => {
|
||||||
|
md.push(`${headingLevel} ${category.title} ${groupTitle}\n\n`)
|
||||||
|
pushGroup(category as ReflectionGroup, md)
|
||||||
|
md.push("\n")
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
if (!hideInPageTOC || isVisible) {
|
||||||
|
if (!hideTocHeaders) {
|
||||||
|
md.push(`${headingLevel} ${groupTitle}\n\n`)
|
||||||
|
}
|
||||||
|
pushGroup(group, md)
|
||||||
|
md.push("\n")
|
||||||
}
|
}
|
||||||
pushGroup(group, md)
|
|
||||||
md.push("\n")
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return md.length > 0 ? md.join("\n") : null
|
return md.length > 0 ? md.join("\n") : null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user