Skip to content

Commit

Permalink
feat: add doc search
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongyunWan committed Oct 24, 2024
1 parent 188d8c4 commit 329c277
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
6 changes: 0 additions & 6 deletions docusaurus/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,6 @@ const config: Config = {
tableOfContents: {
maxHeadingLevel: 5,
},
algolia: {
apiKey: "543db0cadd3173a4b801cd13f89aa996",
indexName: "tugraph-antgroup",
appId: "NDSB2X7NZ3",
contextualSearch: true,
},
navbar: {
logo: {
alt: "Tugraph Site Logo",
Expand Down
3 changes: 2 additions & 1 deletion docusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"typecheck": "tsc"
},
"dependencies": {
"@docsearch/react": "^3.6.2",
"@docusaurus/core": "3.5.2",
"@docusaurus/preset-classic": "3.5.2",
"@mdx-js/react": "^3.0.0",
Expand Down Expand Up @@ -49,4 +50,4 @@
"node": ">=18.0"
},
"repository": "https://github.com/liukaiming-alipay/tugraph-db.git"
}
}
4 changes: 4 additions & 0 deletions docusaurus/src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
display: none;
}

#__docusaurus {
padding: 0 120px;
}

.sidebarViewport_node_modules-\@docusaurus-theme-classic-lib-theme-DocRoot-Layout-Sidebar-styles-module {
overflow-y: auto;
}
25 changes: 23 additions & 2 deletions docusaurus/src/theme/DocSidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type DocSidebarType from "@theme/DocSidebar";
import type { WrapperProps } from "@docusaurus/types";
import { useLocation, useHistory } from "react-router-dom";
import { Select } from "antd";
import { DocSearch } from '@docsearch/react';

type Props = WrapperProps<typeof DocSidebarType>;

Expand Down Expand Up @@ -88,13 +89,33 @@ export default function DocSidebarWrapper(props: Props): JSX.Element {
flexDirection: "column",
}}
>
<div>
<div style={{display: 'flex', alignItems: 'center'}}>
<Select
defaultValue={getCurrentVersion()}
style={{ width: 120, margin: "16px 0 8px 8px" }}
style={{ width: 120, margin: "10px 4px 8px 8px" }}
options={versions.map((item) => ({ value: item, label: item }))}
onChange={onVersionChange}
/>
<div style={{ margin: "10px 4px 8px 8px" }}>
<DocSearch
{...{
apiKey: "829a7e48ddbd6916e159c003391543a0",
indexName: "zhongyunwanio",
appId: "DGYVABHR0M",
searchParameters: {
facetFilters: [`docusaurus_tag:docs-${getCurrentVersion()}_${getCurrentLanguage()}-current`],
},
transformItems: (items) => {
return items.map(item => {
return {
...item,
url: '/docs' + item?.url?.split('/tugraph-db')[1] ?? ''
};
})
},
}}
/>
</div>
</div>
<DocSidebar {...props} />
</div>
Expand Down

0 comments on commit 329c277

Please sign in to comment.