Skip to content

Commit af158db

Browse files
committed
add AI search (test)
1 parent 677c905 commit af158db

File tree

6 files changed

+201
-6
lines changed

6 files changed

+201
-6
lines changed

docusaurus.config.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@ const config: Config = {
88
title: "Open LLM Vtuber",
99
tagline: "与你的专属 Live2D AI 虚拟伴侣进行实时语音互动",
1010
customFields: {
11+
mendableAnonKey: "e9107444-aa01-467d-8ad2-f19b9dff4f83",
1112
thirdline: "支持所有主流大语言模型,跨平台运行",
12-
showcaseImages: [
13-
'img/i1.jpg',
14-
'img/i2.jpg',
15-
'img/i3.jpg',
16-
'img/i4.jpg',
17-
],
13+
showcaseImages: ["img/i1.jpg", "img/i2.jpg", "img/i3.jpg", "img/i4.jpg"],
1814
},
1915
favicon: "img/favicon.ico",
2016

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@docusaurus/preset-classic": "^3.7.0",
2020
"@docusaurus/theme-mermaid": "^3.7.0",
2121
"@docusaurus/theme-search-algolia": "^3.7.0",
22+
"@mendable/search": "^0.0.206",
2223
"clsx": "^2.0.0",
2324
"prism-react-renderer": "^2.3.0",
2425
"react": "^18.0.0",

src/css/custom.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,22 @@
2828
--ifm-color-primary-lightest: #4fddbf;
2929
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
3030
}
31+
32+
/* Reduce width on mobile for Mendable Search */
33+
@media (max-width: 767px) {
34+
.mendable-search {
35+
width: 200px;
36+
}
37+
}
38+
39+
@media (max-width: 500px) {
40+
.mendable-search {
41+
width: 150px;
42+
}
43+
}
44+
45+
@media (max-width: 380px) {
46+
.mendable-search {
47+
width: 140px;
48+
}
49+
}

src/theme/Footer/index.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React, {type ReactNode} from 'react';
2+
import Footer from '@theme-original/Footer';
3+
import type FooterType from '@theme/Footer';
4+
import type {WrapperProps} from '@docusaurus/types';
5+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
6+
import { MendableFloatingButton } from '@mendable/search';
7+
8+
/**
9+
* Footer wrapper component that adds the Mendable floating button
10+
* This enables users to access AI chat functionality from any page
11+
*/
12+
type Props = WrapperProps<typeof FooterType>;
13+
14+
export default function FooterWrapper(props: Props): ReactNode {
15+
const {
16+
siteConfig: { customFields },
17+
} = useDocusaurusContext();
18+
19+
return (
20+
<>
21+
<MendableFloatingButton anon_key={customFields.mendableAnonKey as string} />
22+
<Footer {...props} />
23+
</>
24+
);
25+
}

src/theme/SearchBar.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// By default, the classic theme does not provide any SearchBar implementation
2+
// If you swizzled this, it is your responsibility to provide an implementation
3+
// Tip: swizzle the SearchBar from the Algolia theme for inspiration:
4+
// npm run swizzle @docusaurus/theme-search-algolia SearchBar
5+
6+
import React from 'react';
7+
import { MendableSearchBar } from '@mendable/search';
8+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
9+
10+
/**
11+
* Mendable AI search bar component
12+
* This component integrates Mendable's AI-powered search functionality with keyword search
13+
* Users can type to see immediate keyword search results or ask AI questions
14+
*/
15+
export default function SearchBar(): JSX.Element {
16+
const {
17+
siteConfig: { customFields },
18+
} = useDocusaurusContext();
19+
20+
return (
21+
<div className="mendable-search">
22+
<MendableSearchBar
23+
anon_key={customFields.mendableAnonKey as string}
24+
style={{ accentColor: '#25c2a0', darkMode: false }}
25+
placeholder="Search..."
26+
dialogPlaceholder="Ask me anything about Open LLM VTuber..."
27+
showSimpleSearch={true}
28+
/>
29+
</div>
30+
);
31+
}

0 commit comments

Comments
 (0)