You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vitepress/docs/config/algolia-search.md

1.3 KiB

Theme Config: Algolia Search

The themeConfig.algolia option allows you to use Algolia DocSearch. To enable it, you need to provide at least apiKey and indexName:

module.exports = {
  themeConfig: {
    algolia: {
      apiKey: 'your_api_key',
      indexName: 'index_name'
    }
  }
}

For more options, check out Algolia DocSearch's documentation. You can pass any extra option alongside other options, e.g. passing searchParameters:

module.exports = {
  themeConfig: {
    algolia: {
      apiKey: 'your_api_key',
      indexName: 'index_name',
      searchParameters: {
        facetFilters: ['tags:guide,api']
      }
    }
  }
}

Internationalization (i18n)

If you have multiple locales in your documentation and you have defined a locales object in your themeConfig:

module.exports = {
  themeConfig: {
    locales: {
      // ...
    },
    algolia: {
      apiKey: 'your_api_key',
      indexName: 'index_name'
    }
  }
}

VitePress will automatically add a lang facetFilter to the searchParameters.facetFilter array with the correct language value. Algolia automatically adds the correct facet filter based on the lang attribute on the <html> tag. This will match search results with the currently viewed language of the page.