emersonbottero / vitepress-plugin-search

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

Search does not appear if srcDir config is specified in vitepress config #73

Closed adarshmadrecha closed 8 months ago

adarshmadrecha commented 1 year ago

Better title of this issue could be "Support for srcDir config"

Just adding the key srcDir in the config will cause the Search component to disappear from the website.

// file: .vitepress\config.js
import { defineConfig } from 'vitepress'

// https://vitepress.dev/reference/site-config
export default defineConfig({
  srcDir: './book', 
  title: "My Awesome Book",   
  }
})
adarshmadrecha commented 1 year ago

This issue could be because the plugin is specifically looking only at root directory.

Ref: https://github.com/emersonbottero/vitepress-plugin-search/blob/460a8561047cb7d561e7cfbc429088198c043562/src/index.ts#L52

So, in order to support srcDir option, it should be modified to

 return await IndexSearch(config.base, options); 
pranali98-cpu commented 1 year ago

I am also facing this same issue. Repo to reproduce this error: https://github.com/icaibook/audittrail

emersonbottero commented 1 year ago

@adarshmadrecha , @pranali98-cpu you are doing something wrong. the base has other function , it only has meaning after deploying the page. is used to handle subdomains.

@pranali98-cpu , your example has the wrong script, when not using the default docs you must specify the origin.

like vitepress dev book.

close this issue if the above fix your problem