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

hexo-algolia-gmagon

v1.1.0

Published

Index your content in Algolia Search API

Downloads

6

Readme

Index content in Algolia Search API. Support web site all page index creation code source from https://www.npmjs.com/package/hexo-algolia

Install

Compatible with node>=4.0.0.

$ npm install --save hexo-algolia-gmagon

Public Facing Search Options

You can configure Algolia integration to your hexo website with the _config.yml file:

algolia:
  applicationID: 'applicationID'
  apiKey: 'apiKey'
  indexName: '...'

| Config Key | | | --- | --- | | applicationID | Your Algolia Application ID | | apiKey | A Search-Only API key | | indexName | The name of the Algolia index to use |

These configuration values are accessible from your hexo theme, to be used with Algolia JavaScript client.

Hexo Helpers

Helpers are provided to make your life easier.

Algolia JavaScript Client Tags

The plugin provides an easy way to add Algolia JavaScript API Client either locally (served by hexo) or remotely (via Algolia CDN).

<%- algolia_search() %>

Renders as:

<script src="/assets/algolia/algoliasearchLite.min.js" async></script>
<%- algolia_search_cdn() %>

Renders as:

<script src="https://cdn.jsdelivr.net/algoliasearch/3/algoliasearchLite.min.js" async></script>

Configuration <meta> Tag

You can make your index configuration available to your page and client-side scripts by adding the algolia_config() hexo helper in the <head> of your document.

<%- algolia_search_config() %>

Renders as:

<meta property="algolia:search" data-application-id="..." data-api-key="..." data-index-name="...">

You can access the exposed configuration by querying the data attribute of the algolia:search meta tag:

<script>
const algoliaConfig = document.querySelector('meta[property="algolia:search"]').dataset;

const client = algoliasearch(algoliaConfig.applicationID, algoliaConfig.apiKey);
const index = client.initIndex(algoliaConfig.indexName);
</script>

Indexing Content

Content can be indexed from the command line with the help of the hexo algolia command.

$ ./node_modules/.bin/hexo algolia

API Key

A separate API Key must be provided as an environment variable named HEXO_ALGOLIA_INDEXING_KEY. Create it with these limited write access permissions: Add records, Delete records, List indices, Delete index.

$ export HEXO_ALGOLIA_INDEXING_KEY=…
$ ./node_modules/.bin/hexo algolia

Usage

$ ./node_modules/.bin/hexo help algolia
Usage: ./node_modules/.bin/hexo algolia

Description:
Index your content in Algolia Search API

Options:
  --chunk-size=5000  Chunk size for each batch of content to index
  --dry-run          Does not push content to Algolia
  --flush            Does not reset the Algolia index before starting the indexation

Security Concerns

Never store your Admin API Key as apiKey in the _config.yml file: it would give full control of your Algolia index to others and you don't want to face the consequences.

Please read Algolia Security guide thoroughly if you need some more informations about this.

License

MIT