1.1.0 • Published 5 years ago

gatsby-plugin-algolia-index v1.1.0

Weekly downloads
14
License
MIT
Repository
github
Last release
5 years ago

Gatsby plugin Algolia index

Build Status

🚧 This plugin is work in progress 🚧

Feel free to open issues for any questions or ideas

$ yarn add gatsby-plugin-algolia-index

First add credentials to a .env file, which you won't commit. If you track this in your file, and especially if the site is open source, you will leak your admin API key. This would mean anyone is able to change anything on your Algolia index.

// .env.${process.env.NODE_ENV}
ALGOLIA_APP_ID=XXX
ALGOLIA_API_KEY=XXX
require('dotenv').config({
  path: `.env.${process.env.NODE_ENV}`,
})

// gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-plugin-algolia-index`,
      options: {
        appId: process.env.ALGOLIA_APP_ID,
        apiKey: process.env.ALGOLIA_API_KEY,
        indexName: process.env.ALGOLIA_INDEX_NAME, // for all queries
        path: 'path/to/custom/indexing-config' // optional
        chunkSize: 10000, // default: 1000
      },
    },
  ],
}

// algolia-index-config.js
// (graphql: GraphQlClient) => Promise<[]<{indexName: string, indexData: []<any>}>>

module.exports = async (/*graphql*/) => [
  { indexName: 'index1', indexData: [{ hello: '1' }] },
  { indexName: 'index2', indexData: [{ hello: '2' }] },
]
1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago