-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚗️ (docs) Replace Algolia search with Community Search
- Loading branch information
1 parent
1e3aafc
commit 8a6c7cd
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |