Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svelte-algolia

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-algolia

Algolia plugin for Svelte

  • 0.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by33.33%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 29 Oct 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc