
Usage
HTML
Available parameters
Parameter | Required? | Type | Description |
---|---|---|---|
appId | Yes | String | Find the Application ID in the Algolia dashboard |
apiKey | Yes | String | Find the API key in the Algolia dashboard |
siteID | Yes | String | Find the Netlify Site ID in crawler.algolia.com |
branch | Yes | String | Target git branch or branches. It’s either fixed, such as main, or dynamic using process.env.HEAD |
selector | Yes | String | The HTML element that the Autocomplete menu will replace. It may not be an input element.Default is div#search . |
analytics | No | Boolean | Indicates whether to enable search analytics. Default is true |
hitsPerPage | No | Number | Number of results to display. Default is 5 |
placeholder | No | String | Search input placeholder text. Default is Search... |
openOnFocus | No | Boolean | Indicates whether to open the panel on focus when there’s no query. Default is true |
detached | No | String | Decide when the search popup should open in detached mode (full screen, modal). Can be set to true or false to always or never go into detached mode.Default is: { detached: { mediaQuery: '(max-width: 500px)' }, detached: false, } |
theme | No | Object | Change the appearance of the Autocomplete menu. |
Multiple git branches
If you’ve set up the plugin to index multiple branches using thebranches
option,
each configured branch has a dedicated index.
You also need to pass the information of which index you want to search in using the branch
parameter of the integration.
To get access to the currently building branch,
you can configure your build tool to forward the HEAD
environment variable.
For instance, with webpack
’s environment plugin configured to forward HEAD
, you would pass branch: process.env.HEAD
.
If you’ve configured your plugin to index only specific branches, you need to duplicate the logic here so that it picks the correct branch only when appropriate.
You can also use wildcards in the branch names.
For instance, with branches = ['main', 'develop', 'feat/*']
, and using webpack’s environment plugin to inject HEAD
, here’s how the snippet could look like:
JavaScript
Theme
You can theme the input and the autocomplete by using thetheme
property.
JavaScript
