0.3.4 • Published 7 months ago

@tryghost/algolia-netlify v0.3.4

Weekly downloads
1
License
MIT
Repository
github
Last release
7 months ago

Algolia Netlify

Netlify Functions to listen to Ghost Webhooks on post changes and update defined Algolia search index.

Usage

Set up Algolia

First step is to grab the API keys and Application ID from Algolia. For the setup we need both, the "Search-Only API Key" as well as the "Admin API Key".

The Admin API Key can either be the general one, or can be created just for this specific search index.

If you decide to create a new API key, you want to make sure that the generated key has the following authorizations on your index:

  • Search (search)
  • Add records (addObject)
  • Delete records (deleteObject)
  • List indexes (listIndexes)
  • Delete index (deleteIndex)

Set up Netlify Functions

The Ghost Algolia tooling uses Ghost Webhooks to index and update posts. The scripts that receive and process the webhooks are hosted by Netlify Functions:

  1. Deploy to Netlify by clicking on this button: Deploy to Netlify
  2. Click 'Connect to Github' and give Netlify permission
  3. Configure your site
    • Choose a repository name
    • Set 'TRUE' to trigger indexing
    • Algolia Application ID
    • The Algolia Admin API key or and API key with the permissions as described above
    • The name of the index you want to use
    • Set the NETLIFY_KEY to be used with the target URL

Set up Ghost Webhooks

Ghost webhooks will initiate posts to be indexed to Algolia. This can be a new entry, an update, or a removal. On Ghost's admin panel, create a new Custom Integration (Ghost Admin Settings Integrations Custom Integrations) and the following webhooks:

  1. post.published

  2. post.published.edited

  3. post.unpublished

  4. post.deleted

These webhooks will trigger an index on every future change of posts.

To run an initial index of all the content, you can use the handy CLI from our Ghost Algolia tooling. Head over here and follow the instructions from there.

Security

To avoid unauthorized access to the Netlify functions endpoints, we highly recommend to setup the NETLIFY_KEY variable. This key is currently optional but will be enforced in the future.

Develop

This is a mono repository, managed with lerna.

Follow the instructions for the top-level repo. 1. git clone this repo & cd into it as usual 2. Run yarn to install top-level dependencies.

To run this package locally, you will need to copy the existing .env.example file to .env and fill it with the correct keys.

By running

  • yarn serve

you will create a server on localhost:9000 where your functions will be exposed to listen to (e. g. http://localhost:9000/.netlify/functions/post-unpublished), so you can use them in your local Ghost instance as Webhook target URL.

Test

  • yarn lint run just eslint
  • yarn test run lint and tests

Copyright & License

Copyright (c) 2013-2023 Ghost Foundation - Released under the MIT license.

0.3.2

10 months ago

0.3.4

7 months ago

0.3.3

8 months ago

0.3.0

11 months ago

0.2.0

11 months ago

0.1.13

2 years ago

0.1.11

2 years ago

0.1.10

3 years ago

0.1.8

3 years ago

0.1.9

3 years ago

0.1.7

3 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.2

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago