angular/adev/shared-docs/interfaces/search-results.ts
Andrew Scott 6f87dd3af6 refactor(docs-infra): Update search results to display content when it is matched (#57298)
This commit updates the search results to query for the content as well
as a snippet of the content for display when it's the content that
matches the query rather than any of the headers.

PR Close #57298
2024-08-13 12:07:48 -07:00

56 lines
1.5 KiB
TypeScript

/*!
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export interface SnippetResult {
value: string;
matchLevel: 'none' | 'full' | string;
}
/* The interface represents Algolia search result item. */
export interface SearchResult {
/* The url link to the search result page */
url: string;
/* The hierarchy of the item */
hierarchy: Hierarchy;
/* The unique id of the search result item */
objectID: string;
/**
* The type of the result. A content result will have
* matched the content. A result of type 'lvl#' may have i
* matched a lvl above it. For example, a type 'lvl3' may be
* included in results because its 'lvl2' header matched the query.
*/
type: string;
/** Documentation content (not headers) */
content: string | null;
/** Snippets of the matched text */
_snippetResult: {
hierarchy?: {
lvl0?: SnippetResult;
lvl1?: SnippetResult;
lvl2?: SnippetResult;
lvl3?: SnippetResult;
lvl4?: SnippetResult;
};
content?: SnippetResult;
};
}
/* The hierarchy of the item */
export interface Hierarchy {
/* It's kind of the page i.e `Docs`, `Tutorials`, `Reference` etc. */
lvl0: string | null;
/* Typicaly it's the content of H1 of the page */
lvl1: string | null;
/* Typicaly it's the content of H2 of the page */
lvl2: string | null;
lvl3: string | null;
lvl4: string | null;
lvl5: string | null;
lvl6: string | null;
}