eth-algolia-filters
v2.3.5
Published
The purpose of this package was to make an easy way to compare tags from a vue's endpoint/view with facets in Algolia
Downloads
55
Maintainers
Readme
The reasoning
The purpose of this package was to make an easy way to compare tags from a vue's endpoint/view with facets in Algolia
So the quick and easy (for now) is comparing tags with facets by looping through the facets that are returned by algolia, and the tags from the vue's router, the tags could be anything you want to pass in.
- Keep in mind this was built specifically for a company, so the need of "nameFilterConversion" method won't apply, so make sure you're using the same names of your tags in your algolia attributes. Maybe later I can make this black boxed so anyone can pass in overrides they need.
How to use
step 1:
install the package
npm i eth-algolia-filters
step 2:
Determine which filterType you want to build up. Right now "filters" is the only type that can be rendered atm
when you want to use the "createFilters" method, there are 3 arguments:
- filterType (string): This determines dynamically which methods to call to build the final object.
- facets (object): This is used to loop through each one to compare on the keys & values from the tags passed in.
- tags (array): This is used to loop though to determine if the tag exists in any of the facets that were passed in.
import {createFilters} from 'eth-algolia-filters'
const filtered = createFilters({
filterType: 'filters',
facets,
tags
})
step 3:
When you get the object back it will looks something like below example. Depending on the tags and facets being passed
in, yours will look differently. The example below is with facets of {division: {Men: 1}, 'facet-division.lvl0': {Men: 1}}
and tags
of ['men']
being passed in.
{
"filters": "(division:\"Men\" OR facet-division.lvl0:\"Men\")"
}