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

docsearch.js

Package Overview
Dependencies
Maintainers
33
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docsearch.js - npm Package Compare versions

Comparing version 2.5.2 to 2.6.0

66

CHANGELOG.md

@@ -1,2 +0,24 @@

<a name="2.5.2"></a>
# [2.6.0](https://github.com/algolia/docsearch/compare/v2.5.2...v2.6.0) (2018-11-07)
### Bug Fixes
* **deps:** update dependency algolia-aerial to v1.3.4 ([7e72fe0](https://github.com/algolia/docsearch/commit/7e72fe0))
* **deps:** update dependency algolia-aerial to v1.5.3 ([665438e](https://github.com/algolia/docsearch/commit/665438e))
* **deps:** update dependency algolia-frontend-components to v0.0.35 ([bd5c03f](https://github.com/algolia/docsearch/commit/bd5c03f))
* **deps:** update dependency autocomplete.js to ^0.30.0 ([21eb76a](https://github.com/algolia/docsearch/commit/21eb76a))
* **deps:** update dependency autocomplete.js to ^0.31.0 ([6c65eb2](https://github.com/algolia/docsearch/commit/6c65eb2))
* **deps:** update dependency chalk to v2 ([#323](https://github.com/algolia/docsearch/issues/323)) ([f8962bd](https://github.com/algolia/docsearch/commit/f8962bd))
* **deps:** update dependency deepmerge to v2 ([#324](https://github.com/algolia/docsearch/issues/324)) ([db212d0](https://github.com/algolia/docsearch/commit/db212d0))
* **deps:** update dependency progress to v2 ([#325](https://github.com/algolia/docsearch/issues/325)) ([a99347a](https://github.com/algolia/docsearch/commit/a99347a))
* **wording:** fixed case of DocSearch ([#262](https://github.com/algolia/docsearch/issues/262)) ([d451545](https://github.com/algolia/docsearch/commit/d451545))
### Features
* **css:** Update menu on small screen ([b5733d2](https://github.com/algolia/docsearch/commit/b5733d2))
* **docsearch:** Add custom classes on titles for better crawling ([fc79098](https://github.com/algolia/docsearch/commit/fc79098))
## [2.5.2](https://github.com/algolia/docsearch/compare/v2.5.1...v2.5.2) (2017-12-07)

@@ -6,3 +28,2 @@

<a name="2.5.1"></a>
## [2.5.1](https://github.com/algolia/docsearch/compare/v2.5.0...v2.5.1) (2017-11-28)

@@ -12,3 +33,2 @@

<a name="2.5.0"></a>
# [2.5.0](https://github.com/algolia/docsearch/compare/v2.4.1...v2.5.0) (2017-11-28)

@@ -28,3 +48,2 @@

<a name="2.4.1"></a>
## [2.4.1](https://github.com/algolia/docsearch/compare/v2.4.0...v2.4.1) (2017-08-08)

@@ -34,3 +53,2 @@

<a name="2.4.0"></a>
# [2.4.0](https://github.com/algolia/docsearch/compare/v2.3.3...v2.4.0) (2017-08-08)

@@ -40,3 +58,2 @@

<a name="2.3.3"></a>
## [2.3.3](https://github.com/algolia/docsearch/compare/v2.3.2...v2.3.3) (2017-03-27)

@@ -51,3 +68,2 @@

<a name="2.3.2"></a>
## [2.3.2](https://github.com/algolia/docsearch/compare/v2.3.1...v2.3.2) (2017-03-27)

@@ -57,3 +73,2 @@

<a name="2.3.1"></a>
## [2.3.1](https://github.com/algolia/docsearch/compare/v2.3.0...v2.3.1) (2017-02-23)

@@ -63,3 +78,2 @@

<a name="2.3.0"></a>
# [2.3.0](https://github.com/algolia/docsearch/compare/v2.2.1...v2.3.0) (2017-02-08)

@@ -69,3 +83,2 @@

<a name="2.2.1"></a>
## [2.2.1](https://github.com/algolia/docsearch/compare/v2.2.0...v2.2.1) (2017-01-11)

@@ -75,3 +88,2 @@

<a name="2.2.0"></a>
# [2.2.0](https://github.com/algolia/docsearch/compare/v2.1.8...v2.2.0) (2016-12-13)

@@ -81,3 +93,2 @@

<a name="2.1.8"></a>
## [2.1.8](https://github.com/algolia/docsearch/compare/v2.1.7...v2.1.8) (2016-10-04)

@@ -87,3 +98,2 @@

<a name="2.1.7"></a>
## [2.1.7](https://github.com/algolia/docsearch/compare/v2.1.6...v2.1.7) (2016-10-03)

@@ -98,3 +108,2 @@

<a name="2.1.6"></a>
## [2.1.6](https://github.com/algolia/docsearch/compare/v2.1.5...v2.1.6) (2016-10-02)

@@ -104,3 +113,2 @@

<a name="2.1.5"></a>
## [2.1.5](https://github.com/algolia/docsearch/compare/v2.1.4...v2.1.5) (2016-09-15)

@@ -115,3 +123,2 @@

<a name="2.1.4"></a>
## [2.1.4](https://github.com/algolia/docsearch/compare/v2.1.3...v2.1.4) (2016-08-03)

@@ -121,3 +128,2 @@

<a name="2.1.3"></a>
## [2.1.3](https://github.com/algolia/docsearch/compare/v2.1.2...v2.1.3) (2016-08-03)

@@ -127,3 +133,2 @@

<a name="2.1.2"></a>
## [2.1.2](https://github.com/algolia/docsearch/compare/v2.1.1...v2.1.2) (2016-07-22)

@@ -133,3 +138,2 @@

<a name="2.1.1"></a>
## [2.1.1](https://github.com/algolia/docsearch/compare/v2.1.0...v2.1.1) (2016-07-22)

@@ -139,3 +143,2 @@

<a name="2.1.0"></a>
# [2.1.0](https://github.com/algolia/docsearch/compare/v2.0.7...v2.1.0) (2016-07-07)

@@ -150,3 +153,2 @@

<a name="2.0.7"></a>
## [2.0.7](https://github.com/algolia/docsearch/compare/v2.0.6...v2.0.7) (2016-06-28)

@@ -156,3 +158,2 @@

<a name="2.0.6"></a>
## [2.0.6](https://github.com/algolia/docsearch/compare/v2.0.5...v2.0.6) (2016-06-28)

@@ -172,3 +173,2 @@

<a name="2.0.5"></a>
## [2.0.5](https://github.com/algolia/docsearch/compare/v2.0.4...v2.0.5) (2016-06-21)

@@ -183,3 +183,2 @@

<a name="2.0.4"></a>
## [2.0.4](https://github.com/algolia/docsearch/compare/v2.0.3...v2.0.4) (2016-06-21)

@@ -194,3 +193,2 @@

<a name="2.0.3"></a>
## [2.0.3](https://github.com/algolia/docsearch/compare/v2.0.2...v2.0.3) (2016-06-20)

@@ -200,3 +198,2 @@

<a name="2.0.2"></a>
## [2.0.2](https://github.com/algolia/docsearch/compare/v2.0.1...v2.0.2) (2016-06-14)

@@ -211,3 +208,2 @@

<a name="2.0.1"></a>
## [2.0.1](https://github.com/algolia/docsearch/compare/v2.0.0...v2.0.1) (2016-06-14)

@@ -217,3 +213,2 @@

<a name="2.0.0"></a>
# [2.0.0](https://github.com/algolia/docsearch/compare/v1.3.0...v2.0.0) (2016-06-14)

@@ -228,3 +223,2 @@

<a name="1.3.0"></a>
# [1.3.0](https://github.com/algolia/docsearch/compare/1.2.0...v1.3.0) (2016-06-12)

@@ -234,3 +228,2 @@

<a name="1.2.0"></a>
# [1.2.0](https://github.com/algolia/docsearch/compare/v1.1.3...1.2.0) (2016-06-10)

@@ -247,3 +240,2 @@

<a name="1.1.3"></a>
## [1.1.3](https://github.com/algolia/docsearch/compare/v1.1.2...v1.1.3) (2016-04-04)

@@ -258,3 +250,2 @@

<a name="1.1.2"></a>
## [1.1.2](https://github.com/algolia/docsearch/compare/v1.1.1...v1.1.2) (2016-03-24)

@@ -269,3 +260,2 @@

<a name="1.1.1"></a>
## [1.1.1](https://github.com/algolia/docsearch/compare/v1.1.0...v1.1.1) (2016-03-16)

@@ -293,3 +283,2 @@

<a name="1.1.0"></a>
# [1.1.0](https://github.com/algolia/docsearch/compare/v1.0.2...v1.1.0) (2016-02-01)

@@ -309,3 +298,2 @@

<a name="1.0.2"></a>
## [1.0.2](https://github.com/algolia/docsearch/compare/v1.0.1...v1.0.2) (2015-12-28)

@@ -322,3 +310,2 @@

<a name="1.0.1"></a>
## [1.0.1](https://github.com/algolia/docsearch/compare/v1.0.0...v1.0.1) (2015-12-24)

@@ -333,3 +320,2 @@

<a name="1.0.0"></a>
# [1.0.0](https://github.com/algolia/docsearch/compare/v0.0.7...v1.0.0) (2015-12-24)

@@ -344,3 +330,2 @@

<a name="0.0.7"></a>
## [0.0.7](https://github.com/algolia/docsearch/compare/v0.0.6...v0.0.7) (2015-12-22)

@@ -356,3 +341,2 @@

<a name="0.0.6"></a>
## [0.0.6](https://github.com/algolia/docsearch/compare/v0.0.5...v0.0.6) (2015-12-16)

@@ -362,3 +346,2 @@

<a name="0.0.5"></a>
## [0.0.5](https://github.com/algolia/docsearch/compare/v0.0.4...v0.0.5) (2015-12-16)

@@ -368,3 +351,2 @@

<a name="0.0.4"></a>
## [0.0.4](https://github.com/algolia/docsearch/compare/v0.0.3...v0.0.4) (2015-12-16)

@@ -374,3 +356,2 @@

<a name="0.0.3"></a>
## [0.0.3](https://github.com/algolia/docsearch/compare/v0.0.2...v0.0.3) (2015-12-16)

@@ -380,3 +361,2 @@

<a name="0.0.2"></a>
## [0.0.2](https://github.com/algolia/docsearch/compare/bdac9dd...v0.0.2) (2015-12-16)

@@ -383,0 +363,0 @@

'use strict';
var _main = require('./src/lib/main.js');
var _main = require('./src/lib/main');

@@ -5,0 +5,0 @@ var _main2 = _interopRequireDefault(_main);

@@ -13,7 +13,7 @@ 'use strict';

var _zepto = require('../zepto.js');
var _zepto = require('../zepto');
var _zepto2 = _interopRequireDefault(_zepto);
var _DocSearch = require('../DocSearch.js');
var _DocSearch = require('../DocSearch');

@@ -24,7 +24,13 @@ var _DocSearch2 = _interopRequireDefault(_DocSearch);

Object.defineProperty(window.location, 'href', {
value: 'your url',
configurable: true,
writable: true
});
/**
* Pitfalls:
* Whenever you call new DocSearch(), it will add the a new dropdown markup to
* the page. Because we are clearing the document.body.innerHTML between each
* test, it usually is not a problem.
* Except that autocomplete.js remembers internally how many times it has been
* called, and adds this number to classes of elements it creates.
* DO NOT rely on any .ds-dataset-X, .ds-suggestions-X, etc classes where X is
* a number. This will change if you add or remove tests and will break your
* tests.
**/

@@ -40,2 +46,4 @@ describe('DocSearch', function () {

window.console.warn = _sinon2.default.spy();
window.location.assign = jest.fn();
});

@@ -161,5 +169,5 @@

// Then
var $input = actual.input;
expect($input.text()).toEqual('foo');
expect($input[0].tagName).toEqual('SPAN');
var $inputs = actual.input;
expect($inputs.text()).toEqual('foo');
expect($inputs[0].tagName).toEqual('SPAN');
});

@@ -227,3 +235,5 @@ it('should pass secondary options as instance properties', function () {

// Given
var options = defaultOptions;
var options = _extends({}, defaultOptions, {
handleSelected: function handleSelected() {}
});

@@ -363,3 +373,3 @@ // When

describe('the returned function', function () {
it('calls the Agolia client with the correct parameters', function () {
it('calls the Algolia client with the correct parameters', function () {
// Given

@@ -384,3 +394,3 @@ var actual = docsearch.getAutocompleteSource();

describe('when queryHook is used', function () {
it('calls the Agolia client with the correct parameters', function () {
it('calls the Algolia client with the correct parameters', function () {
// Given

@@ -408,3 +418,3 @@ var actual = docsearch.getAutocompleteSource(false, function (query) {

describe('handleSelected', function () {
it('should change the location', function () {
it('should change the location if no handleSelected specified', function () {
// Given

@@ -422,7 +432,66 @@ var options = {

});
return new Promise(function (resolve) {
expect(window.location.href).toEqual('https://website.com/doc/page');
expect(window.location.assign).toHaveBeenCalledWith('https://website.com/doc/page');
resolve();
});
});
it('should call the custom handleSelected if defined', function () {
// Given
var customHandleSelected = jest.fn();
var options = {
apiKey: 'key',
indexName: 'foo',
inputSelector: '#input',
handleSelected: customHandleSelected
};
var expectedInput = expect.objectContaining({
open: expect.any(Function)
});
var expectedEvent = expect.objectContaining({
type: 'autocomplete:selected'
});
var expectedSuggestion = expect.objectContaining({
url: 'https://website.com/doc/page'
});
// When
var ds = new _DocSearch2.default(options);
ds.autocomplete.trigger('autocomplete:selected', {
url: 'https://website.com/doc/page'
});
return new Promise(function (resolve) {
expect(customHandleSelected).toHaveBeenCalledWith(expectedInput, expectedEvent, expectedSuggestion);
resolve();
});
});
it('should prevent all clicks on links if a custom handleSelected is specified', function () {
// Given
var options = {
apiKey: 'key',
indexName: 'foo',
inputSelector: '#input',
handleSelected: jest.fn()
};
// Building a dropdown with links inside
var ds = new _DocSearch2.default(options);
ds.autocomplete.trigger('autocomplete:shown');
var dataset = (0, _zepto2.default)('.algolia-autocomplete');
var suggestions = (0, _zepto2.default)('<div class="ds-suggestions"></div>');
var testLink = (0, _zepto2.default)('<a href="#">test link</a>');
dataset.append(suggestions);
suggestions.append(testLink);
// Simulating a click on the link
var clickEvent = new _zepto2.default.Event('click');
clickEvent.preventDefault = jest.fn();
testLink.trigger(clickEvent);
return new Promise(function (resolve) {
expect(clickEvent.preventDefault).toHaveBeenCalled();
resolve();
});
});
});

@@ -429,0 +498,0 @@

'use strict';
var _utils = require('../utils.js');
var _utils = require('../utils');

@@ -5,0 +5,0 @@ var _utils2 = _interopRequireDefault(_utils);

@@ -23,15 +23,15 @@ 'use strict';

var _templates = require('./templates.js');
var _templates = require('./templates');
var _templates2 = _interopRequireDefault(_templates);
var _utils = require('./utils.js');
var _utils = require('./utils');
var _utils2 = _interopRequireDefault(_utils);
var _version = require('./version.js');
var _version = require('./version');
var _version2 = _interopRequireDefault(_version);
var _zepto = require('./zepto.js');
var _zepto = require('./zepto');

@@ -135,3 +135,15 @@ var _zepto2 = _interopRequireDefault(_zepto);

}]);
// If user defined its own handleSelected, we prevent clicks on suggestions
// link to do anything
if (handleSelected) {
(0, _zepto2.default)('.algolia-autocomplete').on('click', '.ds-suggestions a', function (event) {
event.preventDefault();
});
}
// Click on suggestions will follow the link, but keyboard navigation still
// need the handleSelected
this.autocomplete.on('autocomplete:selected', handleSelected.bind(null, this.autocomplete.autocomplete));
this.autocomplete.on('autocomplete:shown', this.handleShown.bind(null, this.input));

@@ -195,3 +207,3 @@

input.setVal('');
window.location.href = suggestion.url;
window.location.assign(suggestion.url);
}

@@ -210,3 +222,2 @@ }, {

var otherAlignClass = middleOfInput - middleOfWindow < 0 ? 'algolia-autocomplete-right' : 'algolia-autocomplete-left';
var autocompleteWrapper = (0, _zepto2.default)('.algolia-autocomplete');

@@ -228,2 +239,6 @@ if (!autocompleteWrapper.hasClass(alignClass)) {

if (typeof args.inputSelector !== 'string') {
throw new Error('Error: inputSelector:' + args.inputSelector + ' must be a string. Each selector must match only one element and separated by \',\'');
}
if (!DocSearch.getInputFromSelector(args.inputSelector)) {

@@ -302,3 +317,3 @@ throw new Error('Error: No input element in the page matches ' + args.inputSelector);

var text = _utils2.default.getSnippetedValue(hit, 'content');
var isTextOrSubcatoryNonEmpty = subcategory && subcategory !== '' || displayTitle && displayTitle !== '';
var isTextOrSubcategoryNonEmpty = subcategory && subcategory !== '' || displayTitle && displayTitle !== '';
var isLvl1EmptyOrDuplicate = !subcategory || subcategory === '' || subcategory === category;

@@ -316,3 +331,3 @@ var isLvl2 = displayTitle && displayTitle !== '' && displayTitle !== subcategory;

isSubCategoryHeader: hit.isSubCategoryHeader,
isTextOrSubcatoryNonEmpty: isTextOrSubcatoryNonEmpty,
isTextOrSubcategoryNonEmpty: isTextOrSubcategoryNonEmpty,
category: category,

@@ -319,0 +334,0 @@ subcategory: subcategory,

@@ -15,3 +15,3 @@ 'use strict';

var _version = require('./version.js');
var _version = require('./version');

@@ -18,0 +18,0 @@ var _version2 = _interopRequireDefault(_version);

@@ -13,3 +13,3 @@ 'use strict';

var templates = {
suggestion: '\n <div class="' + suggestionPrefix + '\n {{#isCategoryHeader}}' + suggestionPrefix + '__main{{/isCategoryHeader}}\n {{#isSubCategoryHeader}}' + suggestionPrefix + '__secondary{{/isSubCategoryHeader}}\n ">\n <div class="' + suggestionPrefix + '--category-header">\n <span class="' + suggestionPrefix + '--category-header-lvl0">{{{category}}}</span>\n </div>\n <div class="' + suggestionPrefix + '--wrapper">\n <div class="' + suggestionPrefix + '--subcategory-column">\n <span class="' + suggestionPrefix + '--subcategory-column-text">{{{subcategory}}}</span>\n </div>\n {{#isTextOrSubcatoryNonEmpty}}\n <div class="' + suggestionPrefix + '--content">\n <div class="' + suggestionPrefix + '--subcategory-inline">{{{subcategory}}}</div>\n <div class="' + suggestionPrefix + '--title">{{{title}}}</div>\n {{#text}}<div class="' + suggestionPrefix + '--text">{{{text}}}</div>{{/text}}\n </div>\n {{/isTextOrSubcatoryNonEmpty}}\n </div>\n </div>\n ',
suggestion: '\n <a class="' + suggestionPrefix + '\n {{#isCategoryHeader}}' + suggestionPrefix + '__main{{/isCategoryHeader}}\n {{#isSubCategoryHeader}}' + suggestionPrefix + '__secondary{{/isSubCategoryHeader}}\n "\n aria-label="Link to the result"\n href="{{{url}}}"\n >\n <div class="' + suggestionPrefix + '--category-header">\n <span class="' + suggestionPrefix + '--category-header-lvl0">{{{category}}}</span>\n </div>\n <div class="' + suggestionPrefix + '--wrapper">\n <div class="' + suggestionPrefix + '--subcategory-column">\n <span class="' + suggestionPrefix + '--subcategory-column-text">{{{subcategory}}}</span>\n </div>\n {{#isTextOrSubcategoryNonEmpty}}\n <div class="' + suggestionPrefix + '--content">\n <div class="' + suggestionPrefix + '--subcategory-inline">{{{subcategory}}}</div>\n <div class="' + suggestionPrefix + '--title">{{{title}}}</div>\n {{#text}}<div class="' + suggestionPrefix + '--text">{{{text}}}</div>{{/text}}\n </div>\n {{/isTextOrSubcategoryNonEmpty}}\n </div>\n </a>\n ',
suggestionSimple: '\n <div class="' + suggestionPrefix + '\n {{#isCategoryHeader}}' + suggestionPrefix + '__main{{/isCategoryHeader}}\n {{#isSubCategoryHeader}}' + suggestionPrefix + '__secondary{{/isSubCategoryHeader}}\n suggestion-layout-simple\n ">\n <div class="' + suggestionPrefix + '--category-header">\n {{^isLvl0}}\n <span class="' + suggestionPrefix + '--category-header-lvl0 ' + suggestionPrefix + '--category-header-item">{{{category}}}</span>\n {{^isLvl1}}\n {{^isLvl1EmptyOrDuplicate}}\n <span class="' + suggestionPrefix + '--category-header-lvl1 ' + suggestionPrefix + '--category-header-item">\n {{{subcategory}}}\n </span>\n {{/isLvl1EmptyOrDuplicate}}\n {{/isLvl1}}\n {{/isLvl0}}\n <div class="' + suggestionPrefix + '--title ' + suggestionPrefix + '--category-header-item">\n {{#isLvl2}}\n {{{title}}}\n {{/isLvl2}}\n {{#isLvl1}}\n {{{subcategory}}}\n {{/isLvl1}}\n {{#isLvl0}}\n {{{category}}}\n {{/isLvl0}}\n </div>\n </div>\n <div class="' + suggestionPrefix + '--wrapper">\n {{#text}}\n <div class="' + suggestionPrefix + '--content">\n <div class="' + suggestionPrefix + '--text">{{{text}}}</div>\n </div>\n {{/text}}\n </div>\n </div>\n ',

@@ -16,0 +16,0 @@ footer: '\n <div class="' + footerPrefix + '">\n Search by <a class="' + footerPrefix + '--logo" href="https://www.algolia.com/docsearch">Algolia</a>\n </div>\n ',

@@ -9,3 +9,3 @@ 'use strict';

var _zepto = require('./zepto.js');
var _zepto = require('./zepto');

@@ -246,3 +246,3 @@ var _zepto2 = _interopRequireDefault(_zepto);

* =>
* '<mark>This is an unefinished sentenced</mark>…'
* '<mark>This is an unfinished sentence</mark>…'
* @param {object} object Hit object returned by the Algolia API

@@ -249,0 +249,0 @@ * @param {string} property Object key to look for

@@ -6,2 +6,2 @@ 'use strict';

});
exports.default = '2.5.2';
exports.default = '2.6.0';

@@ -7,3 +7,3 @@ 'use strict';

var _zepto = require('autocomplete.js/zepto.js');
var _zepto = require('autocomplete.js/zepto');

@@ -10,0 +10,0 @@ var _zepto2 = _interopRequireDefault(_zepto);

{
"name": "docsearch.js",
"version": "2.5.2",
"version": "2.6.0",
"description": "Add an autocomplete dropdown to your documentation",
"main": "dist/npm/index.js",
"scripts": {
"dev": "./scripts/dev",
"dev:docs": "./scripts/dev-docs",
"serve": "./scripts/serve",
"doctoc": "doctoc --maxlevel 3 README.md CONTRIBUTING.md",
"build": "./scripts/build",
"build:css": "./scripts/build-css",
"build:js": "./scripts/build-js",
"build:docs": "./scripts/build-docs",
"docs:build": "cd ./docs && yarn build",
"docs:serve": "cd ./docs && yarn serve",
"docs:deploy": "cd ./docs && yarn deploy",
"doctoc": "doctoc --maxlevel 3 README.md CONTRIBUTING.md",
"lint": "./scripts/lint",
"format:scss": "prettier --write ./src/**/*.scss",
"format:md": "prettier --write '**/*.md'",
"release": "./scripts/release",
"release:beta": "./scripts/release-beta",
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
"test": "jest --coverage && npm run lint",
"test:watch": "jest --watch"
"serve": "./scripts/serve",
"test": "./scripts/test",
"test:watch": "./scripts/test-watch",
"postinstall": "cd ./docs && yarn install"
},

@@ -40,36 +42,37 @@ "files": [

"devDependencies": {
"autoprefixer": "7.2.1",
"autoprefixer": "9.1.1",
"babel-cli": "6.26.0",
"babel-core": "6.26.0",
"babel-eslint": "8.0.3",
"babel-core": "6.26.3",
"babel-eslint": "8.2.6",
"babel-istanbul": "0.12.2",
"babel-jest": "21.2.0",
"babel-loader": "7.1.2",
"babel-plugin-rewire": "1.1.0",
"babel-preset-env": "1.6.1",
"babel-jest": "23.6.0",
"babel-loader": "7.1.5",
"babel-plugin-rewire": "1.2.0",
"babel-preset-env": "1.7.0",
"babel-preset-stage-3": "6.24.1",
"conventional-changelog-cli": "1.3.5",
"cssnano": "3.10.0",
"doctoc": "1.3.0",
"eslint": "4.12.1",
"eslint-config-algolia": "13.0.1",
"eslint-config-prettier": "2.9.0",
"eslint-plugin-import": "2.8.0",
"eslint-plugin-jest": "21.4.2",
"eslint-plugin-prettier": "2.3.1",
"gh-pages": "1.1.0",
"jest": "21.2.1",
"jsdom": "11.5.1",
"conventional-changelog-cli": "2.0.11",
"cssnano": "4.1.4",
"doctoc": "1.3.1",
"eslint": "5.4.0",
"eslint-config-algolia": "13.2.3",
"eslint-config-prettier": "2.10.0",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-jest": "21.27.1",
"eslint-plugin-prettier": "2.7.0",
"jest": "23.6.0",
"jsdom": "11.12.0",
"json": "9.0.6",
"mversion": "1.10.1",
"node-sass": "4.7.2",
"onchange": "3.3.0",
"postcss-cli": "4.1.1",
"prettier": "1.9.1",
"live-server": "1.2.0",
"mversion": "1.12.0",
"node-sass": "4.9.4",
"onchange": "4.1.0",
"parallelshell": "3.0.2",
"postcss-cli": "6.0.1",
"prettier": "1.14.3",
"pretty-bytes-cli": "2.0.0",
"semver": "5.4.1",
"sinon": "4.1.2",
"uglify-js": "3.2.1",
"webpack": "3.10.0",
"webpack-dev-server": "2.9.7"
"semver": "5.6.0",
"sinon": "6.3.5",
"uglify-js": "3.4.9",
"webpack": "3.12.0",
"webpack-cli": "3.1.2"
},

@@ -79,6 +82,9 @@ "peerDependencies": {},

"algoliasearch": "^3.24.5",
"autocomplete.js": "^0.29.0",
"autocomplete.js": "0.32.0",
"hogan.js": "^3.0.2",
"to-factory": "^1.0.0"
"request": "^2.87.0",
"stack-utils": "^1.0.1",
"to-factory": "^1.0.0",
"zepto": "^1.2.0"
}
}

@@ -1,306 +0,51 @@

![DocSearch](https://cdn.rawgit.com/algolia/docsearch/master/docs/img/docsearch-logo-horizontal_dark.svg)
The easiest way to add search to your documentation. For free.
Check out our [website][1] to add an outstanding search to your documentation.
[![Version][version-svg]][package-url] [![Build Status][travis-svg]][travis-url] [![Coverage Status][coveralls-svg]][coveralls-url] [![License][license-image]][license-url] [![Downloads][downloads-image]][downloads-url] [![jsDelivr Hits][jsdelivr-badge]][jsdelivr-url]
[version-svg]: https://img.shields.io/npm/v/docsearch.js.svg?style=flat-square
[package-url]: https://npmjs.org/package/docsearch.js
[travis-svg]: https://img.shields.io/travis/algolia/docsearch/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/algolia/docsearch
[coveralls-svg]: https://img.shields.io/coveralls/algolia/docsearch/master.svg?style=flat-square
[coveralls-url]: https://coveralls.io/github/algolia/docsearch?branch=docs%2Fbadges
[license-image]: http://img.shields.io/badge/license-MIT-green.svg?style=flat-square
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/docsearch.js.svg?style=flat-square
[downloads-url]: http://npm-stat.com/charts.html?package=docsearch.js
[docsearch-website]: https://community.algolia.com/docsearch/?utm_medium=social-owned&utm_source=GitHub&utm_campaign=docsearch%20repository
[docsearch-website-docs]: https://community.algolia.com/docsearch/documentation/?utm_medium=social-owned&utm_source=GitHub&utm_campaign=docsearch%20repository
[jsdelivr-badge]: https://data.jsdelivr.com/v1/package/npm/docsearch.js/badge
[jsdelivr-url]: https://www.jsdelivr.com/package/npm/docsearch.js
![Bootstrap][7]
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
## Table of Contents
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
- [Introduction](#introduction)
- [Setup](#setup)
- [Customization](#customization)
- [Attribution](#attribution)
- [Default styling](#default-styling)
- [Advanced styling](#advanced-styling)
- [Custom options](#custom-options)
- [Autocomplete options](#autocomplete-options)
- [Docsearch Options](#docsearch-options)
- [Algolia options](#algolia-options)
- [Contributions and development workflow](#contributions-and-development-workflow)
- [Related projects](#related-projects)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
<!-- START documentation -->
[![DocSearch][1]][8]
## Introduction
The easiest way to add search to your documentation. For free.
We're scratching our own itch here. As developers, we spend a lot of time
reading documentation, and it isn't always easy to find the information we need.
[![npm version][2]](https://npmjs.org/package/docsearch.js)
[![build][3]](https://travis-ci.org/algolia/docsearch)
[![coverage][4]](https://coveralls.io/github/algolia/docsearch)
[![License][5]](./LICENSE)
[![Downloads][6]](https://npm-stat.com/charts.html?package=docsearch.js)
[![jsDelivr Hits][7]](https://www.jsdelivr.com/package/npm/docsearch.js)
Not blaming anyone here. Building a good search for a documentation is a complex
challenge. We happen to have a lot of experience doing that, and we want to
share it with the world. For free.
DocSearch will crawl your documentation website, push its content to an Algolia
index, and allow you to add a dropdown search menu for your users to find
relevant content in no time.
Just submit the form on the [website][16] and we'll get back to you with what
you need to integrate your new search into your website.
Check out our [website][8] for a complete explanation and documentation.
1. We'll crawl your documentation pages,
2. We'll configure your search experience,
3. You'll need to add a bit of JavaScript and CSS code to your website.
[![Bootstrap demo][9]][8]
If you prefer to DIY, you can run the [scraper][28] in your own infra.
## Related projects
## Setup
DocSearch is made of 3 repositories:
Once we've crawled your documentation website we'll send you the credentials you
need to add the following code snippet to your website:
- [algolia/docsearch][10] contains the `docsearch.js` code source and the
documentation website.
- [algolia/docsearch-configs][11] contains the JSON files representing all the
configs for all the documentations DocSearch is powering
- [algolia/docsearch-scraper][12] contains the crawler we use to extract data
from your documentation. The code is open-source and you can run it from
a Docker image
```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
<script type="text/javascript">
docsearch({
apiKey: '<API_KEY>',
indexName: '<INDEX_NAME>',
inputSelector: '<YOUR_INPUT_DOM_SELECTOR>'
});
</script>
```
You can also install docsearch via `npm`:
```sh
npm install --save docsearch.js
```
## Customization
### Attribution
We're happy to provide DocSearch free of charge for your site, and you're
welcome to customise that experience in a way that works for you; all we ask is
that Algolia be attributed within the search context. For example, in the
default implementation, we place a small "Search by Algolia" logo in the
corner. If you prefer to roll your own UX, you'll need to make sure that this
logo is included in your implementation as well.
### Default styling
The default colorscheme is white and gray:
![Default colorscheme][17]
To update the colors to suit your website, you just need to override a few
colors. Here is an example of a CSS file that you can use as a basis to
set white and purple colors.
```css
/* Bottom border of each suggestion */
.algolia-docsearch-suggestion {
border-bottom-color: #3A3DD1;
}
/* Main category headers */
.algolia-docsearch-suggestion--category-header {
background-color: #4B54DE;
}
/* Highlighted search terms */
.algolia-docsearch-suggestion--highlight {
color: #3A33D1;
}
/* Highligted search terms in the main category headers */
.algolia-docsearch-suggestion--category-header .algolia-docsearch-suggestion--highlight {
background-color: #4D47D5;
}
/* Currently selected suggestion */
.aa-cursor .algolia-docsearch-suggestion--content {
color: #272296;
}
.aa-cursor .algolia-docsearch-suggestion {
background: #EBEBFB;
}
/* For bigger screens, when displaying results in two columns */
@media (min-width: 768px) {
/* Bottom border of each suggestion */
.algolia-docsearch-suggestion {
border-bottom-color: #7671df;
}
/* Left column, with secondary category header */
.algolia-docsearch-suggestion--subcategory-column {
border-right-color: #7671df;
background-color: #F2F2FF;
color: #4E4726;
}
}
```
### Advanced styling
If you want to do heavy changes to the way results are displayed, you might find
it easier to directly edit the `scss` files in this repository.
[`_variables.scss`][18]
contains all the color, breakpoints and size definitions while
[`main.scss`][19]
holds the structure of the display.
You can regenerate the whole final `css` file from those `scss` files by running
`npm run build:css`. The resulting files will be found in `./dist/cdn/`.
All you have to do now is change the `link` tag that was loading the default
styling from our CDN, to one that is loading your newly compiled file.
## Custom options
DocSearch is a wrapper around the [autocomplete.js][20] library that gets its
results from the Algolia API. As such, you can use any options provided by
[autocomplete.js][21] and by the Algolia API.
### Autocomplete options
You can pass any options to the underlying `autocomplete` instance through
the`autocompleteOptions` parameter. You will find all `autocomplete` options in
its [own documentation][22].
You can also listen to `autocomplete` events through the `.autocomplete`
property of the `docsearch` instance.
```javascript
var search = docsearch({
apiKey: '<API_KEY>',
indexName: '<INDEX_NAME>',
inputSelector: '<YOUR_INPUT_DOM_SELECTOR>',
debug: true,
autocompleteOptions: {
// See https://github.com/algolia/autocomplete.js#options
// For full list of options
}
});
// See https://github.com/algolia/autocomplete.js#custom-events
// For full list of events
search.autocomplete.on('autocomplete:opened', function(e) {
// Do something when the dropdown menu is opened
});
```
### Docsearch Options
#### handleSelected
We already bind the autocomplete:selected event inside the docsearch.
If you want to replace the default behavior you can pass the `handleSelected` option.
```javascript
var search = docsearch({
apiKey: '<API_KEY>',
indexName: '<INDEX_NAME>',
inputSelector: '<YOUR_INPUT_DOM_SELECTOR>',
handleSelected: function (input, event, suggestion) {
}
});
```
#### queryHook
If you want modify the query before it is send to Algolia you can pass the `queryHook` option.
```javascript
var search = docsearch({
apiKey: '<API_KEY>',
indexName: '<INDEX_NAME>',
inputSelector: '<YOUR_INPUT_DOM_SELECTOR>',
queryHook: function (query) {
return query + "_modified";
}
});
```
#### transformData
If you want to modify the hits before displaying them you can make use of the
`transformData` option
```
var search = docsearch({
apiKey: '<API_KEY>',
indexName: '<INDEX_NAME>',
inputSelector: '<YOUR_INPUT_DOM_SELECTOR>',
transformData: function (hits) {
// modify hits
return hits;
}
});
```
### Algolia options
You can also pass any specific option to the Algolia API to change the way
records are returned. You can pass any options to the Algolia API through
the `algoliaOptions` parameter.
```javascript
docsearch({
appId: '<APP_ID>', // if you are running the crawler yourself
apiKey: '<API_KEY>',
indexName: '<INDEX_NAME>',
inputSelector: '<YOUR_INPUT_DOM_SELECTOR>',
algoliaOptions: {
hitsPerPage: 10
}
});
```
You will find all Algolia API options in its [own documentation][23].
<!-- END documentation -->
## Contributions and development workflow
See [CONTRIBUTING](./CONTRIBUTING.md)
<!-- START links -->
[1]: https://community.algolia.com/docsearch/
[1]: ./.github/docsearch-logo.svg
[2]: https://img.shields.io/npm/v/docsearch.js.svg?style=flat-square
[3]: https://img.shields.io/travis/algolia/docsearch/master.svg?style=flat-square
[4]: https://img.shields.io/coveralls/algolia/docsearch/master.svg?style=flat-square
[5]: http://img.shields.io/badge/license-MIT-green.svg?style=flat-square
[5]: https://img.shields.io/badge/license-MIT-green.svg?style=flat-square
[6]: https://img.shields.io/npm/dm/docsearch.js.svg?style=flat-square
[7]: ./docs/bootstrap-docsearch.gif
[8]: #introduction
[9]: #setup
[10]: #customization
[11]: #development-workflow
[12]: #local-example
[13]: #local-build
[14]: #documentation-website
[15]: #macos
[16]: https://community.algolia.com/docsearch/
[17]: https://community.algolia.com/docsearch/img/default-colorscheme.png
[18]: https://github.com/algolia/docsearch/blob/master/src/styles/_variables.scss
[19]: https://github.com/algolia/docsearch/blob/master/src/styles/main.scss
[20]: https://github.com/algolia/autocomplete.js
[21]: https://github.com/algolia/autocomplete.js
[22]: https://github.com/algolia/autocomplete.js#options
[23]: https://www.algolia.com/doc/api-reference/api-parameters/
[24]: https://nodejs.org/en/
[25]: https://jekyllrb.com/
[26]: https://www.ruby-lang.org/en/
[27]: http://bundler.io/
[28]: https://github.com/algolia/docsearch-scraper
<!-- END links -->
[7]: https://data.jsdelivr.com/v1/package/npm/docsearch.js/badge
[8]: https://community.algolia.com/docsearch/
[9]: ./.github/demo.gif
[10]: https://github.com/algolia/docsearch
[11]: https://github.com/algolia/docsearch-configs
[12]: https://github.com/algolia/docsearch-scraper

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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