Socket
Socket
Sign inDemoInstall

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 - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

4

package.json
{
"name": "svelte-algolia",
"version": "0.1.3",
"version": "0.1.4",
"description": "Algolia plugin for Svelte",

@@ -25,3 +25,3 @@ "main": "src/index.js",

"scripts": {
"test": "ava",
"test": "ava --timeout=2m",
"prepublishOnly": "ava"

@@ -28,0 +28,0 @@ },

@@ -5,6 +5,4 @@ <p align="center">

# svelte-algolia
# svelte-algolia &nbsp; [![Test Status](https://github.com/janosh/svelte-algolia/workflows/Tests/badge.svg)](https://github.com/janosh/svelte-algolia/actions) ![NPM version](https://img.shields.io/npm/v/svelte-algolia?color=blue&logo=NPM) ![GitHub](https://img.shields.io/github/license/janosh/svelte-algolia)
[![Test Status](https://github.com/janosh/svelte-algolia/workflows/ci/badge.svg)](https://github.com/janosh/svelte-algolia/actions)
This package was inspired by the official [`gatsby-plugin-algolia`](https://github.com/algolia/gatsby-plugin-algolia).

@@ -27,5 +25,7 @@

```js
import 'dotenv/config' // optional
const algoliaConfig = {
appId: secrets.algoliaAppId,
apiKey: secrets.algoliaAdminKey,
appId: process.env.algoliaAppId,
apiKey: process.env.algoliaAdminKey,
indices: [

@@ -38,4 +38,6 @@ { name: `pokedex`, getData: pokemonDataLoader },

3. Pass your config to the `indexAlgolia` export from this package:
The `getData` function is expected to return an array of objects containing the data you wish to index to Algolia (a product catalog, blog posts, documentation pages, pokémons or whatever). Each object in the data array should have a key named either `id` or `objectID` for Algolia to recognize it and overwrite existing data.
3. Pass your config to `indexAlgolia`:
```js

@@ -47,2 +49,4 @@ import { indexAlgolia } from 'svelte-algolia'

You can call this function whenever you like to update your indices. Typically, you would include in every production build of your app.
## Config Options

@@ -54,7 +58,8 @@

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()
// items and new ones and only uploads changes, otherwise, completely
// overwrites 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
// an ID that's updated every time the item has changed; if not provided, items
// are checked for deep-equality to discover changes
}

@@ -72,3 +77,3 @@ ```

const algoliaConfig = {
// see config options above
// see above
}

@@ -96,2 +101,2 @@

PRs are welcome but best open an issue first to discuss any changes.
PRs are welcome but best [open an issue](https://github.com/janosh/svelte-algolia/issues/new/choose) first to discuss any changes.

@@ -22,5 +22,6 @@ /* eslint-disable no-console */

if (config.verbosity > 0) {
if (config.partialUpdates) console.log(`Algolia: Partial updates enabled`)
if (config.partialUpdates)
console.log(`svelte-algolia: Partial updates enabled`)
console.log(
`Algolia: ${indices.length} ${
`svelte-algolia: ${indices.length} ${
indices.length > 1 ? `indices` : `index`

@@ -76,3 +77,3 @@ } to update`

console.error(
`failed to index to Algolia: ${JSON.stringify(obj, null, 2)}` +
`failed to index to svelte-algolia: ${JSON.stringify(obj, null, 2)}` +
` has neither an 'objectID' nor 'id' key`

@@ -94,5 +95,5 @@ )

await tmpIndex.saveObjects(data)
await tmpIndex.saveObjects(data).wait()
// move the tmp index to the existing index, overwrites the latter
await client.moveIndex(`${name}_tmp`, name)
await client.moveIndex(`${name}_tmp`, name).wait()
if (config.verbosity > 0)

@@ -146,3 +147,3 @@ console.log(`index '${name}': wrote ${data.length} items`)

if (config.verbosity > 1) console.log(JSON.stringify(toIndex, null, 2))
await index.saveObjects(toIndex)
await index.saveObjects(toIndex).wait()
}

@@ -149,0 +150,0 @@

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