Skip to content

Commit 6c1c393

Browse files
cdxkerskeptrunedev
authored andcommitted
feature: docusaurus search plugin
1 parent 93a83f2 commit 6c1c393

File tree

6 files changed

+2806
-3
lines changed

6 files changed

+2806
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ data/*
8282
clients/ts-sdk/dist
8383
clients/ts-sdk/docs
8484
clients/search-component/dist
85+
clients/docusaurus-theme-search/dist
8586
eslint_report.json
8687

8788

@@ -91,4 +92,4 @@ server/migrations/2024-07-26-165058_move_config_to_table/down.sql
9192
server/migrations/2024-07-26-165058_move_config_to_table/up.sql
9293
dist/**
9394

94-
clients/python-sdk/dist
95+
clients/python-sdk/dist
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## Adding into your site
2+
3+
Add the following into your `docusaurus.config.js`
4+
5+
```sh
6+
npm install @trieve/docusaurus-search-theme
7+
```
8+
9+
```js docusaurus.config.js
10+
/** @type {import('@docusaurus/types').Config} */
11+
const config = {
12+
...
13+
themes: [
14+
[
15+
require.resolve("@trieve/docusaurus-search-theme"),
16+
{
17+
apiKey: "tr-****************",
18+
datasetId: "<your-dataset-id>"
19+
defaultSearchQueries: [
20+
"How to use the API reference?",
21+
"Is there a python sdk?",
22+
"How to get started?"
23+
]
24+
}
25+
],
26+
],
27+
};
28+
```
29+
30+
## Configuration options available
31+
32+
| Name | Type | Default |
33+
| -------------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------ |
34+
| datasetId | string | '' |
35+
| apiKey | string | '' |
36+
| chat | boolean | true |
37+
| analytics | boolean | true |
38+
| placeholder | string | "Search..." |
39+
| theme | "light" or "dark" | "light" |
40+
| searchOptions | [AutocompleteReqPayload](https://ts-sdk.trieve.ai/types/types_gen.AutocompleteReqPayload.html) | `{ search_type: "fulltext" }` |
41+
| suggestedQueries | boolean | true |
42+
| defaultSearchQueries | string[] | [] |
43+
| defaultAiQuestions | string[] | [] |
44+
| brandLogoImgSrcUrl | string | null |
45+
| brandName | string | null |
46+
| accentColor | string | #CB53EB |

clients/docusaurus-theme-search/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
"pub": "yarn build && yarn publish --access public"
1919
},
2020
"dependencies": {
21-
"@getcanary/docusaurus-theme-search-pagefind": "^1.0.2",
22-
"@getcanary/web": "^1.0.0",
2321
"@trieve/docusaurus-search-theme": "^0.1.0",
2422
"cli-progress": "^3.12.0",
2523
"micromatch": "^4.0.7",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import path from "path";
2+
3+
/**
4+
* @typedef {import("@docusaurus/types").Plugin} Plugin
5+
* @typedef {import("@docusaurus/types").DocusaurusContext} DocusaurusContext
6+
* @typedef {import("webpack").Configuration} WebpackConfiguration
7+
* @param {DocusaurusContext} context
8+
*/
9+
export default function plugin(context, options) {
10+
/**
11+
* @type {Plugin}
12+
*/
13+
const config = {
14+
name: "docusaurus-trieve-search-theme",
15+
async contentLoaded({ actions }) {
16+
actions.setGlobalData({ options });
17+
},
18+
};
19+
20+
return {
21+
...config,
22+
getThemePath() {
23+
return path.resolve(__dirname, "./theme");
24+
},
25+
};
26+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from "react";
2+
3+
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
4+
import { TrieveModalSearch } from "trieve-search-component";
5+
import "trieve-search-component/dist/index.css";
6+
import { usePluginData } from "@docusaurus/useGlobalData";
7+
8+
const SearchComponent = () => {
9+
const { options } = usePluginData("docusaurus-trieve-search-theme");
10+
11+
return <TrieveModalSearch {...options} />;
12+
};
13+
14+
export default SearchComponent;

0 commit comments

Comments
 (0)