svelte-algolia
This package was inspired by the official gatsby-plugin-algolia
.
Usage
-
Install with yarn
or npm
yarn add -D svelte-algolia
npm i -D svelte-algolia
-
Create an algoliaConfig
:
const algoliaConfig = {
appId: secrets.algoliaAppId,
apiKey: secrets.algoliaAdminKey,
indices: [
{ name: `pokedex`, getData: pokemonDataLoader },
{ name: `hitchHikersGuide`, getData: guideGetter },
],
}
-
Pass your config to the indexAlgolia
export from this package:
import { indexAlgolia } from 'svelte-algolia'
indexAlgolia(algoliaConfig)
Config Options
const defaultConfig = {
verbosity: 1,
partialUpdates: false,
matchFields: [],
}
As a rollup
plugin
To use this package as part of a rollup
build (e.g. in a Svelte or Sapper app), simply include it in your plugins
array:
import { indexAlgolia } from 'svelte-algolia'
const algoliaConfig = {
}
const dev = process.env.NODE_ENV === `development`
export default {
input: './src/index.js',
output: {
file: './build/bundle.js',
format: 'iife',
name: 'bundle'
plugins: [
!dev && indexAlgolia(algoliaConfig),
]
}
}
Contribute
PRs are welcome but best open an issue first to discuss any changes.