docs-util: add sidebar link validation in prep script (#12306)
This commit is contained in:
1 parent
3c967e6753
commit
05b43ecdb5
1 file changed
+20
-6
@@ -144,9 +144,7 @@ async function getAutogeneratedTagSidebarItems(
|
|||||||
return items
|
return items
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkItem(
|
function validateItem(item: Sidebar.RawSidebarItem): void {
|
||||||
item: Sidebar.RawSidebarItem
|
|
||||||
): Promise<Sidebar.RawSidebarItem> {
|
|
||||||
if (!item.type) {
|
if (!item.type) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`ERROR: The following item doesn't have a type: ${JSON.stringify(
|
`ERROR: The following item doesn't have a type: ${JSON.stringify(
|
||||||
@@ -156,9 +154,6 @@ async function checkItem(
|
|||||||
)}`
|
)}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (item.type === "separator") {
|
|
||||||
return item
|
|
||||||
}
|
|
||||||
if (item.type === "sidebar" && !item.sidebar_id) {
|
if (item.type === "sidebar" && !item.sidebar_id) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`ERROR: The following sidebar item doesn't have a sidebar_id: ${JSON.stringify(
|
`ERROR: The following sidebar item doesn't have a sidebar_id: ${JSON.stringify(
|
||||||
@@ -168,6 +163,25 @@ async function checkItem(
|
|||||||
)}`
|
)}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (item.type === "link" && !item.path) {
|
||||||
|
throw new Error(
|
||||||
|
`ERROR: The following link item doesn't have a path: ${JSON.stringify(
|
||||||
|
item,
|
||||||
|
undefined,
|
||||||
|
2
|
||||||
|
)}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkItem(
|
||||||
|
item: Sidebar.RawSidebarItem
|
||||||
|
): Promise<Sidebar.RawSidebarItem> {
|
||||||
|
if (item.type === "separator") {
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
|
||||||
|
validateItem(item)
|
||||||
|
|
||||||
if (item.children) {
|
if (item.children) {
|
||||||
item.children = await checkItems(item.children)
|
item.children = await checkItems(item.children)
|
||||||
|
|||||||
Reference in new issue
Block a user