1.0.2 • Published 4 years ago

netlify-plugin-algolia-export v1.0.2

Weekly downloads
77
License
MIT
Repository
github
Last release
4 years ago

npm.io npm.io npm.io npm.io npm.io

Netlify Algolia Index Export

Netlify plugin to build a search index and export to Algolia. Newer version of netlify-plugin-algolia-index, this one instead exports directly to Algolia.

Demo

Usage

To install, add the plugin in your netlify.toml or use the Netlify plugin directory. No config is required but we show the default options below.

[[plugins]]
  package = "netlify-plugin-algolia-export"

Add algolia config to your deploy environment variables.

Add algolia config to your deploy environment variables

Set ALGOLIA_APPLICATION_ID, ALGOLIA_ADMIN_KEY, and ALGOLIA_INDEX using environment variables: https://docs.netlify.com/configure-builds/environment-variables

These values can be found on the Your API Keys page on your Algolia Dashboard.

Algolia Dashboard showing Your API Keys

Options

The available options.

plugins.inputstyperequireddefaultdescription
excludeArrayfalse[]An array of paths to exclude from the build. e.g. ['/admin', '/404.html']
textLengthNumberfalse7000The length the body of the page content will be truncated to. This is due to indexing limitations on community versions of Algolia, which we assume is the default.
stopwordsArrayfalse[]Additional stopwords. @see stopword

Examples

Exclude files

Your project probably contains some content files that you don't want your users to search. Pass an array of paths (or regex) to the files you don’t want to be indexed.

[[plugins]]
  package = "netlify-plugin-algolia-export"
    [plugins.inputs]
      exclude = ['''^\/admin.*''', '''^\/search.*''', '/404.html']

Exclude Everything BUT Blog Posts

Advanced Regex Alert! This will exclude all files that DON'T match the regex for URLs like /blog/(year)/(month)/(day)/(slug)/index.html.

[[plugins]]
  package = "netlify-plugin-algolia-export"
    [plugins.inputs]
      exclude = ['''^\/(?!blog\/[0-9]{4}\/[0-9]{2}\/[0-9]{2}\/(?!index.html)).*''']

Credit

Based on the Netlify Search Index Plugin by swyx for fetching and parsing the content into something we can index, then split from the original version of netlify-plugin-algolia-index.