Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@algolia/algoliasearch-netlify-frontend

Package Overview
Dependencies
Maintainers
62
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/algoliasearch-netlify-frontend

`algoliasearch-netlify-frontend` is the front-end bundle we recommend to use with our Netlify plugin. It's designed to be compatible with the index structure extracted by the [plugin](../plugin). It **creates a new search input** in your website with an a

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
132
increased by175%
Maintainers
62
Weekly downloads
 
Created
Source

algoliasearch-netlify-frontend

algoliasearch-netlify-frontend is the front-end bundle we recommend to use with our Netlify plugin. It's designed to be compatible with the index structure extracted by the plugin. It creates a new search input in your website with an autocomplete menu providing search as you type results.

Usage

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@algolia/algoliasearch-netlify-frontend@1/dist/algoliasearchNetlify.css" />
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@algolia/algoliasearch-netlify-frontend@1/dist/algoliasearchNetlify.js"></script>
<script type="text/javascript">
  algoliasearchNetlify({
    appId: '<YOUR_ALGOLIA_APP_ID>',
    apiKey: '<YOUR_ALGOLIA_API_KEY>',
    siteId: '<YOUR_NETLIFY_SITE_ID>',
    branch: '<YOUR_TARGET_GIT_BRANCH>',
    selector: 'div#search',
  });
</script>

Frontend plugin light theme

Available options

Here's the full list of options with their default value.

algoliasearchNetlify({
  // Mandatory
  appId: '<YOUR_ALGOLIA_APP_ID>',               // Application ID (Can be found in https://www.algolia.com/api-keys)
  apiKey: '<YOUR_ALGOLIA_API_KEY>',             // Search api key (Can be found in https://www.algolia.com/api-keys)
  siteId: '<YOUR_NETLIFY_SITE_ID>',             // Netlify Site ID (Can be found in https://crawler.algolia.com/admin/netlify)
  branch: '<YOUR_TARGET_GIT_BRANCH>',           // Target git branch, either a fixed one (e.g. 'master') or a dynamic one using `process.env.HEAD`. See "Using Multiple branches" in this doc.
  selector: 'div#search',                       // Where the autocomplete will be spawned (should not be an input)

  // Optional
  analytics: true,                              // Enable search analytics
  hitsPerPage: 5,                               // Amount of results to display
  poweredBy: true,                              // Controls displaying the logo (mandatory with our FREE plan)
  placeholder: 'Search...';                     // Input placeholder
  openOnFocus: true;                            // Open search panel with default search, when focusing input

  // Theme
  theme: {
    mark: '#fff',                               // Color of the matching content
    background: '#23263b',                      // Background Color of the input and the panel
    selected: '#111432',                        // Background Color of the selected item
    text: '#d6d6e7'                             // Color of the title of the items
  }
});

Using multiple branches

If you've setup the plugin to index multiple branches using the branches plugin input, each configured branch has a dedicated index. You'll 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'll need to duplicate the logic here so that it picks the correct branch only when appropriate. For instance, with branches = ['main', 'develop', 'feat/*'], and using webpack's environment plugin to inject HEAD, here's how the snippet could look like:

const currentBranch = process.env.HEAD; // Injected by your build tool
let targetBranch = 'main';
if (currentBranch === 'develop' || currentBranch.startsWith('feat/')) {
  targetBranch = currentBranch;
}
algoliasearchNetlify({
  // ...
  branch: targetBranch,
});

Theme

You can theme the input and the autocomplete by using the theme property.

// Example of dark theme:
{
  theme: {
    mark: '#fff',
    background: '#23263b',
    selected: '#111432',
    text: '#d6d6e7'
  }
}
Dark theme

To go further you should take a look at the autocomplete.js documentation, or implement your own search with InstantSearch.js.

Development & Release

See CONTRIBUTING.md.

Keywords

FAQs

Package last updated on 09 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc