Skip to content

Commit d610094

Browse files
authored
Merge pull request #7802 from gioboa/fix/7437
docs: fix up search results 🍇
2 parents 23b917f + 5bb4a89 commit d610094

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

packages/docs/src/components/docsearch/snippet.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,18 @@ interface SnippetProps<TItem> {
2020

2121
export const Snippet = component$(
2222
({ hit, attribute, tagName = 'span', ...rest }: SnippetProps<any>) => {
23-
const data =
23+
let data =
2424
getPropertyByPath(hit, `_snippetResult.${attribute ?? `hierarchy.${hit.type}`}.value`) ||
25-
getPropertyByPath(hit, attribute ?? `hierarchy.${hit.type}`);
25+
getPropertyByPath(hit, attribute ?? `hierarchy.${hit.type}`) ||
26+
getPropertyByPath(hit, 'hierarchy.lvl0') + ' ' + getPropertyByPath(hit, 'hierarchy.lvl2');
27+
28+
const cleanedData = data.replace('<mark>', '').replace('</mark>', '').toLowerCase();
29+
if (cleanedData === 'runtime-less') {
30+
const paths = hit.url.split('/');
31+
paths.pop();
32+
data = `example: ${paths.pop()}`;
33+
}
34+
2635
return <span {...rest} dangerouslySetInnerHTML={data} />;
2736
}
2837
);

0 commit comments

Comments
 (0)