Skip to content

fix(navigation): prevent undefined error on 404 pages #391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions src/core/runtime/composables/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,11 @@ export const useDocusNavigation = ({ context, state, api }: DocusAddonContext) =
if (index + 1 === paths.length) return links

// If this path links are only 1 long, set the current path children as root
if (links.length === 1) {
links = links[0].children

return links
}
if (links.length === 1) return links[0].children

// Otherwise, find matching path and get its childrens
links = links.find(item => {
const itemPaths = item.to.split('/')

return itemPaths[index] === path
}).children
const match = links.find(item => item.to.split('/')[index] === path)
if (match) return match.children

return links
}, items)
Expand Down