1
0
Fork 0
📘 The easiest way to add search to your documentation.
Find a file
Pixelastic e615957840 docs(readme): Add info about styling and local dev
I've added a screencast in the readme, a screenshot of the default
colorscheme and a copy-paste of the CSS customization example.

The diff of the README is all red because I used
[formd](http://drbunsen.github.io/formd/) on the file to make the
links more readable (it simply uses reference instead of inlining).
2015-12-22 22:21:58 +01:00
dev fix(css): Renaming all ads- prefix to algolia-docsearch- 2015-12-21 19:01:31 +01:00
docs docs(readme): Add info about styling and local dev 2015-12-22 22:21:58 +01:00
scripts chore(scripts): this is bashism 2015-12-18 19:09:33 +01:00
src v0.0.7 2015-12-22 10:56:10 +01:00
test Merge pull request #31 from algolia/fix/override-appid 2015-12-22 10:46:15 +01:00
.babelrc test(DocSearch): Add tests for constructor 2015-12-18 13:17:25 +01:00
.eslintignore chore(release): remove old references to es5-module 2015-12-16 11:42:36 +01:00
.eslintrc chore(skeleton): Provide basic library skeleton 2015-11-26 12:03:01 +01:00
.gitignore test(formatHits): Add tests for formatHits 2015-12-21 16:56:53 +01:00
.npmignore chore(skeleton): Provide basic library skeleton 2015-11-26 12:03:01 +01:00
.travis.yml chore(release): add release process similar to instantsearch.js 2015-12-15 16:15:13 +01:00
CHANGELOG.md v0.0.7 2015-12-22 10:56:10 +01:00
CONTRIBUTING.md chore(release): git add CONTRIBUTING too 2015-12-16 11:53:29 +01:00
index.js feat(main): Add main wrapper 2015-11-26 16:10:06 +01:00
npm-shrinkwrap.json v0.0.7 2015-12-22 10:56:10 +01:00
package.json v0.0.7 2015-12-22 10:56:10 +01:00
README.md docs(readme): Add info about styling and local dev 2015-12-22 22:21:58 +01:00
webpack.config.jsdelivr.babel.js chore(build): allow npm link and inject NODE_ENV 2015-12-16 12:04:01 +01:00
webpack.dev.config.babel.js test(DocSearch): Add tests for constructor 2015-12-18 13:17:25 +01:00

DocSearch

The easiest way to add search to your documentation. For free.

build status NPM version

Check out our website to add an outstanding search to your documentation.

Eslint

Table of Contents

Introduction

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.

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.

Just submit the form on the website and we'll get back to you with what you need to integrate your new search into your website.

  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.

Setup

Once we've crawled your documentation website we'll send you the credentials you need to add the following code snippet to your website:

<link rel="stylesheet" href="//cdn.jsdelivr.net/docsearch.js/0/docsearch.min.css" />
<script type="text/javascript" src="//cdn.jsdelivr.net/docsearch.js/0/docsearch.min.js"></script>
<script type="text/javascript">
docSearch({
  apiKey: '<API_KEY>',
  indexName: '<INDEX_NAME>',
  inputSelector: '<YOUR_INPUT_DOM_SELECTOR>'
});
</script>

Customization

The default colorscheme is blue and gray:

Default colorscheme

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 and that sets white and purples colors.

/* 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 users can also clone the repository, edit the _variables.scss file and re-build the CSS file using npm run build:css.

Development workflow

Local example

We use a simple documentation example website as a way to develop the docsearch library.

Requirements:

npm run dev
# open http://localhost:8080

Local build

  • npm run build:js: will transpile all the JavaScript files inside ./dist. We build a bundled (and bundled + minified) version for CDNs and another one for npm
  • npm run build:css will convert the SCSS to CSS, along with sourcemaps and minified versions
  • npm run build:docs will create the ./docs/documentation.md file from the README.md file, to be displayed on the website.
  • npm run build will run all three previous commands

Documentation website

This is the Jekyll instance running at https://community.algolia.com/docsearch.

Requirements:

npm run dev:docs
# open http://localhost:4000/docsearch/
# Note that it also implicitly starts another server on localhost:8080, to load
the bundled JavaScript from

MacOS

If you are using brew and you had brew install openssl, you may need to configure the build path of eventmachine with

bundle config build.eventmachine --with-cppflags=-I$(brew --prefix openssl)/include