JSPM

  • Created
  • Published
  • Downloads 6523
  • Score
    100M100P100Q122782F
  • License MIT

Provide local search to your documentation site.

Package Exports

  • vitepress-plugin-search
  • vitepress-plugin-search/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vitepress-plugin-search) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

💡 WIP: First working version, no configuration provided!

Provide local search to your documentation site using lunr.
It works for standard vitepress docs using the doc folder.

Getting Started

Basic Steps to make it work!

Installing

npm i vitepress-plugin-search -D

Setup

  • Since we are using the same slot as the default algolia search let's create an alias so our component is used instead
//docs/vite.config.js
import { defineConfig } from "vite";

export default defineConfig({
  resolve: {
    alias: {
      "./components/AlgoliaSearchBox.vue":
        "vitepress-plugin-search/src/Search.vue",
    },
  },
});
  • Add an algolia entry just to pass the v-if in the slots
//.vitepress/config.js
    themeConfig: {
        ...
        algolia: {},
        ...
    }
  • Add lunr_index.js to .gitignore

  • Add scripts to build the index

"prebuild": "npm run index",
"index": "node ./node_modules/vitepress-plugin-search/src/index.js"
  • Build twice before running dev.

  • Build twice on CI/CD

💡 alternatively you can create an script like

"build": "npm run index && vitepress build docs && npm run index && vitepress build docs",