⚗️ (docs) Replace Algolia search with Community Search
This commit is contained in:
@ -16,6 +16,7 @@
|
||||
"api:generate": "dotenv -e ./.env -e ../../.env -- tsx --tsconfig ../builder/tsconfig.json ../builder/src/helpers/server/generateOpenApi.ts && dotenv -e ./.env -e ../../.env -- tsx --tsconfig ../viewer/openapi.tsconfig.json ../viewer/src/helpers/server/generateOpenApi.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@docsearch/react": "^3.5.2",
|
||||
"@docusaurus/core": "2.4.1",
|
||||
"@docusaurus/preset-classic": "2.4.1",
|
||||
"@docusaurus/theme-common": "2.4.1",
|
||||
|
@ -137,3 +137,7 @@ video {
|
||||
.asterix {
|
||||
color: rgb(239, 81, 81);
|
||||
}
|
||||
|
||||
[aria-describedby='community-widget-description'] {
|
||||
display: none !important;
|
||||
}
|
||||
|
55
apps/docs/src/theme/SearchBar/index.js
Normal file
55
apps/docs/src/theme/SearchBar/index.js
Normal file
@ -0,0 +1,55 @@
|
||||
import React, { useCallback, useRef } from 'react'
|
||||
import { DocSearchButton } from '@docsearch/react'
|
||||
import Head from '@docusaurus/Head'
|
||||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'
|
||||
import translations from '@theme/SearchTranslations'
|
||||
let DocSearchModal = null
|
||||
function DocSearch() {
|
||||
// We let user override default searchParameters if she wants to
|
||||
const searchButtonRef = useRef(null)
|
||||
const importDocSearchModalIfNeeded = useCallback(() => {
|
||||
if (DocSearchModal) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
return Promise.all([
|
||||
import('@docsearch/react/modal'),
|
||||
import('@docsearch/react/style'),
|
||||
import('./styles.css'),
|
||||
]).then(([{ DocSearchModal: Modal }]) => {
|
||||
DocSearchModal = Modal
|
||||
})
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<script
|
||||
type="text/javascript"
|
||||
defer
|
||||
src="https://widget.orbit.love/widget.js"
|
||||
/>
|
||||
<script type="text/javascript">
|
||||
{`window.Widget = window.Widget || {};
|
||||
window.Widget = Object.assign({}, window.Widget, {
|
||||
baseUrl: "https://widget.orbit.love/widget/24a80353-75fd-49bd-a928-53dff3f4c097"
|
||||
});`}
|
||||
</script>
|
||||
</Head>
|
||||
|
||||
<DocSearchButton
|
||||
onTouchStart={importDocSearchModalIfNeeded}
|
||||
onFocus={importDocSearchModalIfNeeded}
|
||||
onMouseOver={importDocSearchModalIfNeeded}
|
||||
onClick={() => {
|
||||
window.Widget.toggleWidget()
|
||||
}}
|
||||
ref={searchButtonRef}
|
||||
translations={translations.button}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
export default function SearchBar() {
|
||||
useDocusaurusContext()
|
||||
return <DocSearch />
|
||||
}
|
14
apps/docs/src/theme/SearchBar/styles.css
Normal file
14
apps/docs/src/theme/SearchBar/styles.css
Normal file
@ -0,0 +1,14 @@
|
||||
:root {
|
||||
--docsearch-primary-color: var(--ifm-color-primary);
|
||||
--docsearch-text-color: var(--ifm-font-color-base);
|
||||
}
|
||||
|
||||
.DocSearch-Button {
|
||||
margin: 0;
|
||||
transition: all var(--ifm-transition-fast)
|
||||
var(--ifm-transition-timing-default);
|
||||
}
|
||||
|
||||
.DocSearch-Container {
|
||||
z-index: calc(var(--ifm-z-index-fixed) + 1);
|
||||
}
|
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@ -351,6 +351,9 @@ importers:
|
||||
|
||||
apps/docs:
|
||||
dependencies:
|
||||
'@docsearch/react':
|
||||
specifier: ^3.5.2
|
||||
version: 3.5.2(@algolia/client-search@4.15.0)(@types/react@18.0.28)(react-dom@17.0.2)(react@17.0.2)(search-insights@2.8.3)
|
||||
'@docusaurus/core':
|
||||
specifier: 2.4.1
|
||||
version: 2.4.1(@docusaurus/types@2.3.1)(react-dom@17.0.2)(react@17.0.2)(typescript@5.3.2)
|
||||
|
Reference in New Issue
Block a user