Skip to content

Commit 1bfc9b2

Browse files
authored
Fce 3073/make doc search usable (#249)
Adds Algolia search + AI + AI sidepanel <img width="1627" height="932" alt="image" src="https://github.com/user-attachments/assets/9369a59d-1523-46c0-ae33-246ca5f289ad" /> <img width="1624" height="932" alt="image" src="https://github.com/user-attachments/assets/bfd4d5a1-c34c-46e6-a3a5-260c325459a5" /> <img width="1687" height="1282" alt="image" src="https://github.com/user-attachments/assets/844845bc-2c5c-4fbd-8e0a-59eb39c040c4" />
1 parent aa0875e commit 1bfc9b2

6 files changed

Lines changed: 106 additions & 505 deletions

File tree

docusaurus.config.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Config } from "@docusaurus/types";
22
import type * as Preset from "@docusaurus/preset-classic";
3+
import type { UserThemeConfig as DocSearchThemeConfig } from "@docsearch/docusaurus-adapter";
34
import { BundledLanguage, bundledLanguages } from "shiki";
45
import type { MDXPlugin } from "@docusaurus/mdx-loader";
56
import rehypeShiki, { RehypeShikiOptions } from "@shikijs/rehype";
@@ -255,6 +256,18 @@ const config: Config = {
255256
},
256257
],
257258
},
259+
docsearch: {
260+
appId: "IBX716Q0KT",
261+
apiKey: "5dcaa347f57ca14f8cb59926164dd129",
262+
indexName: "Fishjam",
263+
contextualSearch: true,
264+
searchPagePath: "search",
265+
insights: false,
266+
askAi: {
267+
assistantId: "49fdf088-e614-4b89-86c2-da8c4b566260",
268+
agentStudio: true,
269+
},
270+
},
258271
footer: {
259272
links: [
260273
{
@@ -295,23 +308,11 @@ const config: Config = {
295308
],
296309
copyright: `Copyright © ${new Date().getFullYear()} Software Mansion, Inc. All trademarks and copyrights belong to their respective owners.`,
297310
},
298-
} satisfies Preset.ThemeConfig,
311+
} satisfies Preset.ThemeConfig & DocSearchThemeConfig,
299312

300313
plugins: [
301314
["@docusaurus/plugin-client-redirects", { createRedirects }],
302-
[
303-
require.resolve("docusaurus-lunr-search"),
304-
// exclude old versions and next from search
305-
{
306-
includeRoutes: [
307-
"/docs/tutorials/*",
308-
"/docs/how-to/*",
309-
"/docs/explanation/*",
310-
"/docs/integrations/*",
311-
"/docs/api/*",
312-
],
313-
},
314-
],
315+
"@docsearch/docusaurus-adapter",
315316
[
316317
"docusaurus-plugin-typedoc",
317318
{

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"spellcheck:report": "yarn spellcheck --no-show-suggestions"
2525
},
2626
"dependencies": {
27+
"@docsearch/docusaurus-adapter": "^4.0.0",
2728
"@docusaurus/core": "^3.10.0",
2829
"@docusaurus/faster": "^3.10.0",
2930
"@docusaurus/plugin-client-redirects": "^3.10.0",
@@ -42,7 +43,6 @@
4243
"@types/react": "^19.1.8",
4344
"@types/react-dom": "^19.1.6",
4445
"clsx": "^2.0.0",
45-
"docusaurus-lunr-search": "3.6.0",
4646
"expo-camera": "^16.1.8",
4747
"fastify": "^5.4.0",
4848
"mock-import": "^4.2.1",

src/components/AskAiSidepanel.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { ReactElement } from "react";
2+
import { DocSearchSidepanel } from "@docsearch/react/sidepanel";
3+
import "@docsearch/css/dist/sidepanel.css";
4+
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
5+
6+
export default function AskAiSidepanel(): ReactElement {
7+
const { siteConfig } = useDocusaurusContext();
8+
const { appId, apiKey, indexName, askAi } = siteConfig.themeConfig
9+
.docsearch as any;
10+
11+
return (
12+
<DocSearchSidepanel
13+
appId={appId}
14+
apiKey={apiKey}
15+
indexName={indexName}
16+
assistantId={askAi.assistantId}
17+
agentStudio={askAi.agentStudio}
18+
button={{ variant: "floating" }}
19+
panel={{ variant: "floating", side: "right" }}
20+
/>
21+
);
22+
}

src/css/custom.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,18 @@ h3 .badge {
9191
margin-left: 0.75rem;
9292
}
9393

94+
/* Ask AI sidepanel — fix white color that Docusaurus overrides to transparent */
95+
.DocSearch-Sidepanel-Container {
96+
--docsearch-sidepanel-primary: var(--ifm-color-primary);
97+
--docsearch-sidepanel-primary-dark: var(--ifm-color-primary-dark);
98+
--docsearch-sidepanel-primary-disabled: var(--ifm-color-primary-lightest);
99+
--docsearch-sidepanel-white: #fff;
100+
}
101+
102+
/* Floating trigger button — keep site branding */
103+
.DocSearch-SidepanelButton.floating {
104+
color: white;
105+
background: var(--ifm-color-primary);
106+
}
107+
94108
@import url("./_shiki.css");

src/theme/Root.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { ReactNode } from "react";
2+
import BrowserOnly from "@docusaurus/BrowserOnly";
3+
4+
export default function Root({ children }: { children: ReactNode }): ReactNode {
5+
return (
6+
<>
7+
{children}
8+
<BrowserOnly>
9+
{() => {
10+
const AskAiSidepanel =
11+
require("../components/AskAiSidepanel").default;
12+
return <AskAiSidepanel />;
13+
}}
14+
</BrowserOnly>
15+
</>
16+
);
17+
}

0 commit comments

Comments
 (0)