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

gitbook-plugin-algolia

v2.0.0

Published

Use Algolia as a backend for research

Downloads

31

Readme

Power search using Algolia

Use Algolia as a back-end to index and search your book's content.

This plugins requires gitbook >=4.0.0.

How to use it?

Create an Algolia account

  1. Sign up to Algolia
  2. Set up a basic index.
  3. Access your API keys settings, and keep this page open for the next steps.

Set up the plugin in your book.

  1. Open Settings > Plugins Store interface in the GitBook Editor.
  2. Install the algolia plugin.
  3. Specify the following values in the modal for your book:
    • Algolia Index Name, which is the name of the index you set up in Algolia web.
    • Algolia Application ID, which is your unique application ID for API identification.
    • Algolia Search-Only API Key, which is the unique ID for search queries.
    • Is your Algolia account free, which you leave as true if you have what Algolia call a "Hacker Account".

Or if you prefer, you can declare the plug-in values in the book.json file. Add the plugin and its configuration to your book.json:

{
    "plugins": ["algolia"],
    "pluginsConfig": {
        "algolia": {
            "index": "algolia-index-name",
            "applicationID": "algolia-application-id",
            "publicKey": "algolia-search-only-api-key",
            "freeAccount": "true"
        }
    }
}

Set Algolia Environment Variables

If you are using the GitBook Editor, you can specify the ALGOLIA_PRIVATEKEY in the Settings of your book.

  1. Login to https://www.gitbook.com
  2. Go to the Settings of the book you want to add the environment variable to.
  3. Scroll down to the Environment Variables group.
  4. Add a new variable, named ALGOLIA_PRIVATEKEY, and put your Admin API Key as value.

If you are using the command line, pass your Admin API Key as an environment variable when launching gitbook:

$ ALGOLIA_PRIVATEKEY="algolia-admin-api-key" gitbook serve

A note about the index

WARNING The plugin will replace the entire index at each build phase. Do not use an existing index, unless you no longer require its contents.

When setting up the basic index on Algolia, you will be prompted to generate or import the index so Algolia can begin analysing your book.

You do not need to create the index manually for the plugin to work.

Adding keywords to a page

You can specify explicit keywords for any page.

---
search:
    keywords: ['keyword1', 'keyword2', 'etc.']

---

# My Page

This page will rank better if we search for 'keyword1'.

Disabling indexing of a page

You can disable the indexing of a specific page by adding a YAML header to the page:

---
search: false
---

# My Page

This page is not indexed in by Algolia.

Fine tuning the Algolia search rankings

After having indexed your book at least once, you can configure your Algolia index from your dashboard. You can go to the Ranking settings and tell Algolia how to search your pages. You can see below an example configuration, that tells Algolia to search, by order of importance, the keywords of your pages, their title, and finally their content (body).

Example ranking configuration