docs-util: add sidebar link validation in prep script (#12306)
This commit is contained in:
@@ -144,9 +144,7 @@ async function getAutogeneratedTagSidebarItems(
|
||||
return items
|
||||
}
|
||||
|
||||
async function checkItem(
|
||||
item: Sidebar.RawSidebarItem
|
||||
): Promise<Sidebar.RawSidebarItem> {
|
||||
function validateItem(item: Sidebar.RawSidebarItem): void {
|
||||
if (!item.type) {
|
||||
throw new Error(
|
||||
`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) {
|
||||
throw new Error(
|
||||
`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) {
|
||||
item.children = await checkItems(item.children)
|
||||
|
||||
Reference in New Issue
Block a user