Skip to content

Commit 219fe1f

Browse files
committed
feat: integrate Algolia Agent Studio Ask AI search
Upgrade @docsearch/react to v4.6 for Agent Studio support and add askAi config with a swizzled SearchBar to inject agentStudio flag that Docusaurus 3.9.2 validation doesn't yet recognize.
1 parent 99b06a5 commit 219fe1f

File tree

4 files changed

+45
-192
lines changed

4 files changed

+45
-192
lines changed

docusaurus.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,12 @@ const config = {
185185
// Public API key: it is safe to commit it
186186
apiKey: "e988677555350573b539eb974e2b7891",
187187
indexName: "phcode",
188-
contextualSearch: false
188+
contextualSearch: false,
189+
askAi: {
190+
assistantId: "d43f2205-8075-439d-822b-b3825b74cb49",
191+
apiKey: "0c73a640624ba54f777a5491ee884aa3",
192+
indexName: "markdown-index",
193+
}
189194
},
190195
// Replace with your project's social card
191196
image: "img/socialcard.png",

package-lock.json

Lines changed: 22 additions & 191 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"serveStatic": "http-server build -p 8001 -c-1"
2020
},
2121
"dependencies": {
22+
"@docsearch/css": "^4.6.0",
23+
"@docsearch/react": "^4.6.0",
2224
"@docusaurus/core": "^3.7.0",
2325
"@docusaurus/plugin-client-redirects": "^3.7.0",
2426
"@docusaurus/plugin-google-gtag": "^3.7.0",
@@ -38,6 +40,7 @@
3840
"devDependencies": {
3941
"@docusaurus/module-type-aliases": "3.9.2",
4042
"@docusaurus/types": "3.9.2",
43+
"baseline-browser-mapping": "^2.10.10",
4144
"http-server": "14.1.1",
4245
"shx": "0.4.0"
4346
},

src/theme/SearchBar/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import SearchBar from '@theme-original/SearchBar';
2+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
3+
4+
// Wrap SearchBar to inject agentStudio: true into askAi config.
5+
// Docusaurus 3.9.2's Joi validation doesn't recognize agentStudio yet,
6+
// but @docsearch/react 4.6+ requires it for Agent Studio assistants.
7+
export default function SearchBarWrapper(props) {
8+
const {siteConfig} = useDocusaurusContext();
9+
const askAi = siteConfig.themeConfig.algolia?.askAi;
10+
if (askAi && !askAi.agentStudio) {
11+
askAi.agentStudio = true;
12+
}
13+
return <SearchBar {...props} />;
14+
}

0 commit comments

Comments
 (0)