mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
fix(search): handle cases where slug is undefined
- Extract searchResult to a variable for clarity - Implement fallback mechanism to use objectID or article ID when slug is unavailable - Prevent potential navigation errors with missing slug
This commit is contained in:
@@ -104,7 +104,8 @@ export default function AlgoliaSearchModal({ cRef }) {
|
||||
// 跳转Search结果
|
||||
const onJumpSearchResult = () => {
|
||||
if (searchResults.length > 0) {
|
||||
window.location.href = `${siteConfig('SUB_PATH', '')}/${searchResults[activeIndex].slug}`
|
||||
const searchResult = searchResults[activeIndex]
|
||||
window.location.href = `${siteConfig('SUB_PATH', '')}/${searchResult.slug || searchResult.objectID}`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user