diff --git a/packages/docs/src/components/docsearch/snippet.tsx b/packages/docs/src/components/docsearch/snippet.tsx index 894248a8491..14bd3c44356 100644 --- a/packages/docs/src/components/docsearch/snippet.tsx +++ b/packages/docs/src/components/docsearch/snippet.tsx @@ -20,9 +20,18 @@ interface SnippetProps { export const Snippet = component$( ({ hit, attribute, tagName = 'span', ...rest }: SnippetProps) => { - const data = + let data = getPropertyByPath(hit, `_snippetResult.${attribute ?? `hierarchy.${hit.type}`}.value`) || - getPropertyByPath(hit, attribute ?? `hierarchy.${hit.type}`); + getPropertyByPath(hit, attribute ?? `hierarchy.${hit.type}`) || + getPropertyByPath(hit, 'hierarchy.lvl0') + ' ' + getPropertyByPath(hit, 'hierarchy.lvl2'); + + const cleanedData = data.replace('', '').replace('', '').toLowerCase(); + if (cleanedData === 'runtime-less') { + const paths = hit.url.split('/'); + paths.pop(); + data = `example: ${paths.pop()}`; + } + return ; } );