fix: DocSearch-Hit-source is empty in certain cases #2295
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #2294
Earlier
hit.hierarchy.lvl0
was returned only ifhit._highlightResult
is falsy. But in certain caseshit._highlightResult.hierarchy
is not there even ifhit._highlightResult
is present. This PR returnshit.hierarchy.lvl0
as a fallback always.I'm not sure, but some change in Algolia's response triggered this. Earlier it was working fine. The types still indicate that
hit._highlightResult.hierarchy.lvl0.value
will always be set. So, it might be regression in some other service and other parts might also break 👀docsearch/packages/docsearch-react/src/types/DocSearchHit.ts
Lines 28 to 32 in 3067715
PS: the original issue didn't share the crawler config. Here it is:
Expand
Just sharing in case it's something specific to vitepress-recommended crawler.