diff --git a/docs/src/theme/SearchBar-TEST/index.tsx b/docs/src/theme/SearchBar-TEST/index.tsx deleted file mode 100644 index e16a88e..0000000 --- a/docs/src/theme/SearchBar-TEST/index.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import React from 'react'; -import { DocSearch } from '@docsearch/react'; -import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; -import type { DocSearchHit } from '@docsearch/react'; -import '@docsearch/css'; - -// Define the Algolia config type from Docusaurus theme config -interface AlgoliaConfig { - appId: string; - apiKey: string; - indexName: string; - contextualSearch?: boolean; - externalUrlRegex?: string; - searchParameters?: Record; -} - -export default function SearchBar(): JSX.Element { - const { siteConfig } = useDocusaurusContext(); - const { algolia } = siteConfig.themeConfig as { algolia: AlgoliaConfig }; - - return ( - { - return items.map((item) => { - // Extract the pathname from the URL - const urlPath = new URL(item.url).pathname; - - // Get the enclosing folder (second-to-last path segment) - const pathParts = urlPath.split('/').filter(part => part !== ''); - const enclosingFolder = pathParts.length > 1 - ? pathParts[pathParts.length - 2] - : pathParts[0] || 'root'; - - // Format folder name nicely - const folderDisplay = enclosingFolder - .replace(/-/g, ' ') - .replace(/\b\w/g, (l) => l.toUpperCase()); - - // Build the new lvl0 with path info - const newLvl0 = item.hierarchy.lvl0 - ? `${item.hierarchy.lvl0} › ${folderDisplay}` - : folderDisplay; - - // Update both hierarchy and _highlightResult (which is what displays in UI) - const transformedItem = { - ...item, - hierarchy: { - ...item.hierarchy, - lvl0: newLvl0, - }, - _highlightResult: { - ...item._highlightResult, - hierarchy: { - ...item._highlightResult?.hierarchy, - lvl0: { - ...item._highlightResult?.hierarchy?.lvl0, - value: newLvl0, - }, - }, - }, - }; - - return transformedItem; - }); - }} - /> - ); -} \ No newline at end of file diff --git a/docs/src/theme/SearchBar/index.tsx b/docs/src/theme/SearchBar/index.tsx index 9548899..bbc3286 100644 --- a/docs/src/theme/SearchBar/index.tsx +++ b/docs/src/theme/SearchBar/index.tsx @@ -12,6 +12,13 @@ interface AlgoliaConfig { contextualSearch?: boolean; externalUrlRegex?: string; searchParameters?: Record; + insights?: boolean; + askAi?: { + assistantId: string; + indexName: string; + appId: string; + apiKey: string; + }; } export default function SearchBar(): ReactElement { @@ -23,6 +30,8 @@ export default function SearchBar(): ReactElement { appId={algolia.appId} apiKey={algolia.apiKey} indexName={algolia.indexName} + insights={algolia.insights} + askAi={algolia.askAi} transformItems={(items: DocSearchHit[]) => { return items.map((item) => { // Extract the pathname from the URL