StaticSearch v0.7.0 update

By Craig Buckler

728 words, 4-minute read

search
Image courtesy of Elijah Mears

StaticSearch v0.7.0 was released on . There should be no breaking changes but there are a few new features included fuzzier results generation.

Fuzzy search results #

StaticSearch now finds partial segments of words so there’s less need to type them in full.

A fuzzy setting determines the maximum number of words to fetch. Set it on the web component:

HTML excerpt

<static-search fuzzy="5">
  <p>search</p>
</static-search>

the bind module <input> field:

HTML excerpt

<input type="search" id="staticsearch_search" fuzzy="5">

or as the second argument of the API .find() method:

JavaScript excerpt

const result = await staticsearch.find('my search query', 5);

Keyboard-focusable activation #

The <static-search> activation element which triggers the search dialog is now keyboard-focusable so you can open it by hitting Enter or space.

Activate search from any element #

When using the <static-search> web component, any HTML element can trigger the search dialog by adding a data-static-search attribute, e.g.

HTML excerpt

<a href="#" data-static-search="search">click here to search</a>

Activation element ::part name #

The activation element sets a part attribute name of activate unless you define your own, e.g.

HTML excerpt

<static-search fuzzy="5">
  <p part="trigger">search</p>
</static-search>

Style it using the part name, e.g.

CSS excerpt

static-search::part(trigger) {
  color: #00f;
}

Build directory location #

The StaticSearch indexer now looks for static sites built to the subdirectories:

  1. ./build/
  2. ./dist/
  3. ./dest/
  4. ./out/, or
  5. ./target/

When none exist, it uses the current working directory.

Omit default stop words #

StaticSearch automatically removes common stop words considered insignificant to the meaning of text – such as “and”, “the”, and “but” in English. It supports stop words in Afrikaans (af), Croatian (hr), Czech (cs), Danish (da), Dutch (nl), English (en), Estonian (et), Finnish (fi), French (fr), German (de), Hungarian (hu), Irish (ga), Italian (it), Latvian (lv), Lithuanian (lt), Malay (ms), Norwegian (no), Polish (pl), Portuguese (pt), Romanian (ro), Slovak (sk), Somali (so), Spanish (es), Swahili (sw), Swedish (sv), Turkish (tr), and Zulu (zu).

In some cases, such as smaller sites, you may wish to omit these defaults or use your own set. You can do this on the command line:

terminal

staticsearch -W
# or
staticsearch --ignorestopdefault

in an environment variable:

example .env

# StaticSearch environment variables
STOPWORDS_DEFAULT=false

or using the Node.js API:

index.js example

// run indexer
import { staticsearch } from 'staticsearch';
staticsearch.stopWordsDefault = false;
await staticsearch.index();

Miscellaneous updates #

Minor changes include:

Get started #

The StaticSearch documentation provides a quick start guide, and details about the indexer, web component, bind module, and JavaScript API.

StaticSearch works well with Publican sites. The Publican documentation provides a quick start guide, a detailed set-up guide, API references, and common recipes you can use and adapt for your own projects.