npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tryghost/algolia-netlify

v0.3.4

Published

[Netlify Functions](https://www.netlify.com/products/functions/) to listen to [Ghost Webhooks](https://ghost.org/docs/api/webhooks/) on post changes and update defined [Algolia](https://www.algolia.com/) search index.

Downloads

32

Readme

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

    • Name: Post published
    • Event: Post published
    • Target URL: the endpoint of the post-published function, found on Netlify's admin panel plus the NETLIFY_KEY as a query parameter as defined in the configuration data above (https://YOUR-SITE-ID.netlify.com/.netlify/functions/post-published?key=NETLIFY_KEY)
  2. post.published.edited

    • Name: Post updated
    • Event: Published post updated
    • Target URL: the endpoint of the post-published function, found on Netlify's admin panel plus the NETLIFY_KEY as a query parameter as defined in the configuration data above (https://YOUR-SITE-ID.netlify.com/.netlify/functions/post-published?key=NETLIFY_KEY)
  3. post.unpublished

    • Name: Post unpublished
    • Event: Post unpublished
    • Target URL: the endpoint of the post-published function, found on Netlify's admin panel plus the NETLIFY_KEY as a query parameter as defined in the configuration data above (https://YOUR-SITE-ID.netlify.com/.netlify/functions/post-unpublished?key=NETLIFY_KEY)
  4. post.deleted

    • Name: Post deleted
    • Event: Post deleted
    • Target URL: the endpoint of the post-published function, found on Netlify's admin panel plus the NETLIFY_KEY as a query parameter as defined in the configuration data above (https://YOUR-SITE-ID.netlify.com/.netlify/functions/post-unpublished?key=NETLIFY_KEY)

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.