|
5 | 5 | */
|
6 | 6 | import lunr from "lunr";
|
7 | 7 | import { blocksToText } from "./blocks-to-text";
|
8 |
| -import { ApiDocsEntry, ApiDocsResponse } from "../../language-server/apidocs"; |
9 |
| -import { Toolkit } from "../explore/model"; |
| 8 | +import type { |
| 9 | + ApiDocsEntry, |
| 10 | + ApiDocsResponse, |
| 11 | +} from "../../language-server/apidocs"; |
| 12 | +import type { Toolkit, ToolkitTopic } from "../explore/model"; |
10 | 13 | import {
|
11 | 14 | Extracts,
|
12 | 15 | IndexMessage,
|
@@ -113,12 +116,14 @@ const defaultString = (string: string | undefined): string => {
|
113 | 116 | const exploreSearchableContent = (toolkit: Toolkit): SearchableContent[] => {
|
114 | 117 | const content: SearchableContent[] = [];
|
115 | 118 | toolkit.contents?.forEach((t) => {
|
116 |
| - content.push({ |
117 |
| - id: t.slug.current, |
118 |
| - title: t.name, |
119 |
| - containerTitle: t.name, |
120 |
| - content: t.subtitle + ".\n\n" + blocksToText(t.introduction), |
121 |
| - }); |
| 119 | + if (!isSingletonTopic(t)) { |
| 120 | + content.push({ |
| 121 | + id: t.slug.current, |
| 122 | + title: t.name, |
| 123 | + containerTitle: t.name, |
| 124 | + content: t.subtitle + ".\n\n" + blocksToText(t.introduction), |
| 125 | + }); |
| 126 | + } |
122 | 127 | t.contents?.forEach((e) => {
|
123 | 128 | const contentString = blocksToText(e.content);
|
124 | 129 | const detailContentString = blocksToText(e.detailContent);
|
@@ -231,3 +236,8 @@ export class SearchWorker {
|
231 | 236 | return this.current!;
|
232 | 237 | }
|
233 | 238 | }
|
| 239 | + |
| 240 | +// We have some topics that contain a single item with the same id. |
| 241 | +// There's no sense indexing the topic itself in those cases. |
| 242 | +const isSingletonTopic = (t: ToolkitTopic): boolean => |
| 243 | + t.contents?.length === 1 && t.contents[0].slug.current === t.slug.current; |
0 commit comments