Skip to content

Janpot/site-search

Repository files navigation

site-search

A lightweight self-hosted alternative to DocSearch.

site-search will run your website locally, crawl its pages and index their content in a lunr index. It also provides a node.js request handler that can be initialized with this index to provide a search endpoint for your website.

How to use

  1. Install the package
yarn add -D site-search
  1. Add a site-search.config.js to the root of your project containing
module.exports = {
  siteStartCmd: `yarn start`,
  siteOrigin: 'http://localhost:3000',
  startUrl: '/',
  outputPath: './site-search-index.json',
  rules: [
    {
      hierarchy: [
        { selector: 'h1' },
        { selector: 'h2' },
        { selector: 'h3' },
        { selector: 'h4' },
      ],
      text: { selector: 'p' },
    },
  ],
};
  1. Run site-search:

  2. Add the search endpoint to your app:

const path = require('path');
const handler = require('site-search/handler');
// ...
app.use(
  '/search',
  handler({
    filename: path.resolve(__dirname, '../site-search-index.json'),
  })
);
  1. Now you can use /search?q=foo to find documents matching "foo"

Config

siteStartCmd: Command that should be run to start your website siteOrigin: Url of where the running website can be reached startUrl: Url where crawling should start outputPath: Where to store the resulting index data rules: Rules to extract hierarchy. A bit similar to how Algolia does it

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy