chore: reorganize docs apps (#7228)
* reorganize docs apps * add README * fix directory * add condition for old docs
This commit is contained in:
1 parent
224ebb2154
commit
4fe28f5a95
6187 files changed
+601447
-598226
No files matched your search
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
*
|
||||
* @param {import("@/types").SidebarItemType[]} sidebarItems - The items to add numbers to their titles
|
||||
* @param {number[]} numbering - The current numbering level
|
||||
* @returns {import("@/types").SidebarItemType[]} The modified sidebar items
|
||||
*/
|
||||
export default function numberSidebarItems(sidebarItems, numbering = [1]) {
|
||||
if (!numbering.length) {
|
||||
numbering.push(1)
|
||||
}
|
||||
sidebarItems.forEach((item) => {
|
||||
// append current number to the item's title
|
||||
item.number = `${numbering.join(".")}.`
|
||||
item.title = `${item.number} ${item.title.trim()}`
|
||||
|
||||
if (item.children) {
|
||||
item.children = numberSidebarItems(item.children, [...numbering, 1])
|
||||
}
|
||||
|
||||
numbering[numbering.length - 1]++
|
||||
})
|
||||
|
||||
return sidebarItems
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/** @type {Partial<import("../providers").SidebarItemType>} */
|
||||
const commonOptions = {
|
||||
loaded: true,
|
||||
isPathHref: true,
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../providers").SidebarItemType[]} sidebar
|
||||
* @returns {import("../providers").SidebarItemType[]}
|
||||
*/
|
||||
export function sidebarAttachHrefCommonOptions(sidebar) {
|
||||
return sidebar.map((item) => ({
|
||||
...commonOptions,
|
||||
...item,
|
||||
children: sidebarAttachHrefCommonOptions(item.children || []),
|
||||
}))
|
||||
}
|
||||
Reference in new issue
Block a user