emersonbottero / vitepress-plugin-search

Provide local search to your documentation site.
MIT License
240 stars 30 forks source link

[Question] Is it possible to use this package as a standalone Search? #1

Closed staghouse closed 2 years ago

staghouse commented 2 years ago

I am writing a custom theme and want local Search. Can I use this package without needing to alias Algolia (since it doesnt exist in my custom theme).

If so, can you provide instructions on how?

I have tried to import the component directly using import Search from 'vitepress-plugin-search/src/Search.vue'; but that resolves an error: Uncaught (in promise) TypeError: metaKey.value is undefined in Search.vue at line 68

emersonbottero commented 2 years ago

Strange. It should work. it is just used to detect mac so we can search with Ctrl+K equivalent. you can test commenting the lines that uses it in the node_module folder and also you can try to replace for a DumbSearch component

//docs/vite.config.js
import { defineConfig } from "vite";

export default defineConfig({
  resolve: {
    alias: {
      "./components/YourDumbSearchComponent.vue":
        "vitepress-plugin-search/src/Search.vue",
    },
  },
});

I can't replicate the problem on my pc so I need your help to debug.