mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
c34d5997e9
Add gallery search via Algolia GitOrigin-RevId: 82f306154c990e5ba047b7a7ab9e98f193995ede
20 lines
553 B
JavaScript
20 lines
553 B
JavaScript
import _ from 'lodash'
|
|
import App from '../base'
|
|
import AlgoliaSearch from 'algoliasearch'
|
|
import getMeta from '../utils/meta'
|
|
|
|
export default App.factory('algoliaSearch', function () {
|
|
let wikiIdx
|
|
const algoliaConfig = getMeta('ol-algolia')
|
|
const wikiIndex = _.get(algoliaConfig, 'indexes.wiki')
|
|
if (wikiIndex) {
|
|
const client = AlgoliaSearch(algoliaConfig.appId, algoliaConfig.apiKey)
|
|
wikiIdx = client.initIndex(wikiIndex)
|
|
}
|
|
|
|
const service = {
|
|
searchWiki: wikiIdx ? wikiIdx.search.bind(wikiIdx) : null,
|
|
}
|
|
|
|
return service
|
|
})
|