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

gatsby-plugin-blogsearch

v0.0.2

Published

BlogSearch index building tool for Gatsby

Downloads

3

Readme

BlogSearch index building tool for Gatsby

// Asciidoc references // Documentation: https://asciidoctor.org/docs/user-manual/ // Quick reference: https://asciidoctor.org/docs/asciidoc-syntax-quick-reference/ // Asciidoc vs Markdown: https://asciidoctor.org/docs/user-manual/#comparison-by-example // GitHub Flavored Asciidoc (GFA): https://gist.github.com/dcode/0cfbf2699a1fe9b46ff04c41721dda74

:project-version: 0.0.3 :rootdir: https://github.com/kbumsik/blogsearch

ifdef::env-github[] // Emoji :tip-caption: :bulb: :note-caption: :information_source: :important-caption: :heavy_exclamation_mark: :caution-caption: :fire: :warning-caption: :warning: // URL :imagesdir: https://gist.githubusercontent.com/path/to/gist/revision/dir/with/all/images endif::[]

CAUTION: This is a part of link:{rootdir}[BlogSearch project]. If you would like to know the overall concept, go to link:{rootdir}[the parent directory].

1. Building a search index file

Installation

[source,shell] npm install gatsby-plugin-blogsearch

Configuration

CAUTION: Go to link:{rootdir}#whats-in-the-index[the "What's in the index file" section of the main project]. For more details on how to configure fields.

.gatsby.config.js [source,javascript,options="nowrap",subs="verbatim,attributes"]

module.exports = { ... other Gatsby options ...

plugins: [ { resolve: 'gatsby-plugin-blogsearch', options: { // Generated blogsearch database file. output: 'reactjs.org.gatsby-example.db.wasm', // fields configurations // See: {rootdir}#whats-in-the-index fields: { title: { enabled: true, indexed: true, hasContent: true, }, body: { enabled: true, indexed: true, hasContent: true, }, url: { enabled: true, indexed: true, hasContent: true, }, categories: { enabled: true, indexed: true, hasContent: true, }, tags: { enabled: true, indexed: true, hasContent: true, }, }, // GraphQL query used to fetch all data for the search index. This is // required. query: { allMarkdownRemark { edges { node { fields { slug } frontmatter { title } rawMarkdownBody # excerpt # html } } } site { siteMetadata { siteUrl } } } , // Function used to map the result from the GraphQL query. This should // return an array of items to index in the form of flat objects // containing field properties to index. normalizer: ({ data }) => data.allMarkdownRemark.edges.map(({ node }) => { const slug = (node.fields.slug.charAt(0) !== '/' ? '/' : '') + node.fields.slug; return { title: node.frontmatter.title, body: node.rawMarkdownBody .replace(/[#`[]]+/g, '') .replace(/(.*)/g, '') .replace(/\s+/g, ' '), url: data.site.siteMetadata.siteUrl + slug, categories: slug !== '/' ? slug.substring(1, slug.indexOf('/', 1)) : '', tags: '', }; }), }, }, ... Other Gatsby plugin options ... ], ... Rest of Gatsby options ... };

Example project

Go to demo

2. Enabling the search engine in the webpage

You need to enable the search engine in the web page. Go to link:../blogsearch[blogsearch Engine].

Again, if you would like to understand the concept of BlogSearch, go to link:{rootdir}/[the parent directory].