Getting Started
Demo
This documentation site is built using VitePress and the search experience is powered by Typesense. Click on the search icon to try the plugin out!
Installation
You can install the plugin by running the following command:
sh
$ npm add vitepress-plugin-typesensesh
$ pnpm add vitepress-plugin-typesensesh
$ yarn add vitepress-plugin-typesensesh
$ bun add vitepress-plugin-typesenseConfigure the plugin in your .vitepress/config.ts file.
ts
import { defineConfig, loadEnv } from 'vitepress';
const env = loadEnv('', process.cwd() + '/docs', '');
export default defineConfig({
vite: {
plugins: [
TypesenseSearchPlugin({
typesenseCollectionName: 'YOUR_COLLECTION_NAME',
typesenseServerConfig: {
apiKey: 'YOUR_SEARCH_ONLY_API_KEY',
nodes: [{ url: 'YOUR_TYPESENSE_URL' }],
},
typesenseSearchParameters: {},
// when `indexing` is enabled, the pages will be automatically indexed into Typesense on vitepress buildEnd
indexing: {
enabled: true,
hostname: 'YOUR_DOCUMENTATION_SITE_URL',
typesenseServerConfig: {
apiKey: env.TYPESENSE_ADMIN_API_KEY, // your api key with write permission, create a .env file in your /docs directory
nodes: [{ url: 'YOUR_TYPESENSE_URL' }],
// timeout config, etc...
},
},
}),
],
},
});Run the VitePress build command to populate the pages into Typesense:
sh
$ npm run docs:buildsh
$ pnpm docs:buildsh
$ yarn docs:buildsh
$ bun docs:buildAnd that's it! You can start the development server to preview the plugin in action.