Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions components/ui/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ const InKeepTrigger = dynamic(
},
) as typeof InkeepModalSearchAndChat;

import { DocsSearchItem, EndpointSearchItem } from "@/types";
import {
DocsSearchItem,
EndpointSearchItem,
EnhancedDocsSearchItem,
} from "@/types";
import { Button } from "@telegraph/button";
import { Icon } from "@telegraph/icon";
import { MenuItem } from "@telegraph/menu";
Expand Down Expand Up @@ -72,7 +76,9 @@ const highlightingStyles = {
const NUM_DOCS_HITS = 12;
const NUM_ENDPOINT_HITS = 5;

type ResultItem = (DocsSearchItem & BaseItem) | (EndpointSearchItem & BaseItem);
type ResultItem =
| (EnhancedDocsSearchItem & BaseItem)
| (EndpointSearchItem & BaseItem);

const algoliaAppId = process.env.NEXT_PUBLIC_ALGOLIA_APP_ID || "";
const algoliaSearchApiKey =
Expand Down Expand Up @@ -178,7 +184,7 @@ const DocsSearchResult = ({
)}
</Text>
<Text as="span" size="1" color="gray" weight="regular">
{item.section}
{item.pageTitle ? `${item.pageTitle as string} •` : ""} {item.section}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Page-level results redundantly display title twice

Low Severity

For page-level search results, pageTitle equals title (both are set to frontmatter.title in the indexing script), causing the same title to appear twice in the UI - once as the main title and again in the subtitle. The isPageLevel field exists on EnhancedDocsSearchItem specifically to distinguish page-level from heading-level records, but the display logic doesn't use it. The condition should check !item.isPageLevel && item.pageTitle to only show pageTitle for heading-level results where it provides useful parent-page context.

Fix in Cursor Fix in Web

</Text>
</Box>
</Link>
Expand Down Expand Up @@ -757,7 +763,7 @@ const Autocomplete = () => {
/>
) : (
<DocsSearchResult
item={item as DocsSearchItem}
item={item as EnhancedDocsSearchItem}
onClick={() => autocomplete.setQuery("")}
/>
)}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
"generate-llms": "yarn run open-api-to-md && tsx scripts/generateApiMarkdown.ts && tsx scripts/generateLlmsTxt.ts",
"generate-reference-md": "tsx scripts/generateApiMarkdown.ts",
"index-apis": "tsx scripts/indexApisForSearch.ts",
"index-docs": "tsx scripts/indexDocsForSearch.ts",
"open-api-to-md": "bash scripts/openApiToMd.sh",
"predev": "yarn generate-llms",
"prebuild": "yarn generate-llms && yarn index-apis"
"prebuild": "yarn generate-llms && yarn index-docs && yarn index-apis"
},
"dependencies": {
"@algolia/autocomplete-js": "^1.6.3",
Expand Down
Loading
Loading