Options
All
  • Public
  • Public/Protected
  • All
Menu

haupia.js

haupia.js

This library allows you to create a search results page with little effort. Search, auto-complete, faceting and pagination functions are provided.

Learn more about haupia in the official documentation.

Release Notes

Deutsch

English

Install

npm install haupia.js

Usage


import {haupia} from 'haupia.js'

Below are minimal examples of how to use the functionalities. For more details please open the API documentation.

// basic example
const url = "https://my.haupia.backend";
const preparedSearch = "Homepage";

const fsss = new haupia(url, preparedSearch);
// searching
const page: Page = fsss.search("Example query");
page.renderSearchResultsToHTMLElement(document.getElementById("searchResultWrapper"));
// autocomplete
const options: HaupiaOptions = {
    autocompleteHighlighting: true,
    autocompleteLanguage: "en",
    autocompletePrefixThreshold: 3
}
const fsss = new haupia(url, preparedSearch, options);
fsss.attachAutocompleteWidget(document.getElementById("search-bar"));
// pagination
const page: Page = fsss.search("Example query");
page.renderPaginationToHTMLElement(document.getElementById("paginationWrapper"), 5);
// faceting
const page: Page = fsss.search("Example query");
if (page.facets) {
    const facets: Facet = page.facets.find(facet => facet.name.includes("language"));
    // ...
}

Generated using TypeDoc