Socket
Socket
Sign inDemoInstall

svelte-algolia

Package Overview
Dependencies
17
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    svelte-algolia

Algolia plugin for Svelte


Version published
Weekly downloads
3
decreased by-40%
Maintainers
1
Install size
909 kB
Created
Weekly downloads
 

Readme

Source

Banner

svelte-algolia

Test Status

This package was inspired by the official gatsby-plugin-algolia.

Usage

  1. Install with yarn or npm

    yarn add -D svelte-algolia
    
    npm i -D svelte-algolia
    
  2. Create an algoliaConfig:

    const algoliaConfig = {
      appId: secrets.algoliaAppId,
      apiKey: secrets.algoliaAdminKey,
      indices: [
        { name: `pokedex`, getData: pokemonDataLoader },
        { name: `hitchHikersGuide`, getData: guideGetter },
      ],
    }
    
  3. Pass your config to the indexAlgolia export from this package:

    import { indexAlgolia } from 'svelte-algolia'
    
    indexAlgolia(algoliaConfig)
    

Config Options

const defaultConfig = {
  verbosity: 1, // 0, 1 or 2 for no/some/lots of logging
  partialUpdates: false, // if true, figures out diffs between existing
  // items and new ones and only uploads, otherwise, completely overrides
  // each index on every call to indexAlgolia()
  matchFields: [], // (only used when partialUpdates is true) keys of fields to
  // check for whether an item has changed; could e.g. be a timestamp, hash or
  // an ID that's updated every time the item has changed
}

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:

// rollup.config.js
import { indexAlgolia } from 'svelte-algolia'

const algoliaConfig = {
  // see config options above
}

// check if running in build or development mode
const dev = process.env.NODE_ENV === `development`

export default {
  input: './src/index.js',
  output: {
    file: './build/bundle.js',
    format: 'iife',
    name: 'bundle'
    plugins: [
      // to save Algolia indexing operations, you may want to only
      // update your indices when building your app for production
      !dev && indexAlgolia(algoliaConfig),
    ]
  }
}

Contribute

PRs are welcome but best open an issue first to discuss any changes.

Keywords

FAQs

Last updated on 29 Oct 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc