[Take 2] Throw error if children entry can't be found, even if early access (#35523)
This commit is contained in:
@@ -30,14 +30,19 @@ export default async function createTree(originalPath, rootPath, previousTree) {
|
||||
try {
|
||||
mtime = await getMtime(filepath)
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT' && filepath.split(path.sep).includes('early-access')) {
|
||||
// Do not throw an error if Early Access is not available.
|
||||
console.warn(
|
||||
`${filepath} could not be turned into a Page, but is ignored because it's early-access`
|
||||
)
|
||||
if (error.code !== 'ENOENT') {
|
||||
throw error
|
||||
}
|
||||
// Throw an error if we can't find a content file associated with the children: entry.
|
||||
// But don't throw an error if the user is running the site locally and hasn't cloned the Early Access repo.
|
||||
if (originalPath === path.join('content', 'early-access')) {
|
||||
return
|
||||
}
|
||||
throw error
|
||||
throw new Error(
|
||||
`Cannot find a content file at ${originalPath}. Fix the children frontmatter entry "/${path.basename(
|
||||
originalPath
|
||||
)}" in ${path.dirname(originalPath)}/index.md.\n`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,9 +119,6 @@ export default async function createTree(originalPath, rootPath, previousTree) {
|
||||
// (early exit instead of returning a tree). So let's
|
||||
// mutate the `page.children` so we can benefit from the
|
||||
// ability to reload the site tree on consective requests.
|
||||
if (child !== 'early-access') {
|
||||
console.warn(`Remove '${child}' from ${item.page.children}`)
|
||||
}
|
||||
item.page.children = item.page.children.filter((c) => c !== child)
|
||||
}
|
||||
return subTree
|
||||
|
||||
Reference in New Issue
Block a user