mirror of
https://github.com/halo-dev/docs.git
synced 2026-01-22 03:00:10 +08:00
chore: use selfhosted-meilisearch as docs search engine (#357)
使用自建的 Meilisearch 作为文档搜索引擎,代替 Algolia。 /kind improvement ```release-note None ```
This commit is contained in:
25
src/theme/SearchBar.js
Normal file
25
src/theme/SearchBar.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import React, { useEffect } from "react";
|
||||
import "meilisearch-docsearch/css";
|
||||
|
||||
export default function SearchBarWrapper(props) {
|
||||
useEffect(() => {
|
||||
const docsearch = require("meilisearch-docsearch").default;
|
||||
|
||||
const destroy = docsearch({
|
||||
container: "#docsearch",
|
||||
host: "https://docsearch.halo.run",
|
||||
// Default Search API Key
|
||||
// Use it to search from the frontend
|
||||
apiKey:
|
||||
"4b16205faa360eaa1ee5add67c0d265a4ca1e898ffbea199fe23d487a24c9bc8",
|
||||
indexUid: "docs",
|
||||
});
|
||||
|
||||
return () => destroy();
|
||||
}, []);
|
||||
return (
|
||||
<>
|
||||
<div id="docsearch"></div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user