Merge pull request #9989 from explosion/docs/update-algolia-search-api [ci skip]

This commit is contained in:
Ines Montani 2022-01-05 14:14:42 +01:00 committed by GitHub
commit 005e23a525
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
} }
} }
} }