Update website to use new Algolia search API

This commit is contained in:
Ines Montani 2022-01-05 13:21:06 +01:00
parent 00e7bf5ffd
commit a437ca6737
4 changed files with 6 additions and 2 deletions

View File

@ -22,7 +22,8 @@
"list": "89ad33e698" "list": "89ad33e698"
}, },
"docSearch": { "docSearch": {
"apiKey": "371e26ed49d29a27bd36273dfdaf89af", "appId": "Y1LB128RON",
"apiKey": "bb601a1daab73e2dc66faf2b79564807",
"indexName": "spacy" "indexName": "spacy"
}, },
"binderUrl": "explosion/spacy-io-binder", "binderUrl": "explosion/spacy-io-binder",

View File

@ -6,13 +6,14 @@ import Icon from './icon'
import classes from '../styles/search.module.sass' import classes from '../styles/search.module.sass'
export default function Search({ id = 'docsearch', placeholder = 'Search docs', settings = {} }) { export default function Search({ id = 'docsearch', placeholder = 'Search docs', settings = {} }) {
const { apiKey, indexName } = settings const { apiKey, indexName, appId } = settings
if (!apiKey && !indexName) return null if (!apiKey && !indexName) return null
const [initialized, setInitialized] = useState(false) const [initialized, setInitialized] = useState(false)
useEffect(() => { useEffect(() => {
if (!initialized) { if (!initialized) {
setInitialized(true) setInitialized(true)
window.docsearch({ window.docsearch({
appId,
apiKey, apiKey,
indexName, indexName,
inputSelector: `#${id}`, inputSelector: `#${id}`,

View File

@ -41,6 +41,7 @@ export const pageQuery = graphql`
docSearch { docSearch {
apiKey apiKey
indexName indexName
appId
} }
} }
} }

View File

@ -235,6 +235,7 @@ export const pageQuery = graphql`
docSearch { docSearch {
apiKey apiKey
indexName indexName
appId
} }
} }
} }