@coveops/taxonomy-breadcrumb
v1.0.1
Published
Generates all permutations of breadcrumbs for specified field values, useful when needing to specify a hierarchy between those values.
Downloads
18
Maintainers
Keywords
Readme
TaxonomyBreadcrumb
Generates the appropriate permutation of breadcrumbs based on the specified field values, useful when needing to specify a hierarchy between those values.
This component is a result template component (see Result Templates).
This component handles both single and multi-value fields.
For example, using the following fields
- @level1 = ['a', 'b']
- @level2 = ['c', 'd']
along with the default separator will generate the following breadcrumbs based on the values of the specified fields:
- a>c
- a>d
- b>c
- b>d
Disclaimer: This component was built by the community at large and is not an official Coveo JSUI Component. Use this component at your own risk.
Getting Started
Testing the Component
For quick testing, you can add the script from unpkg:
<script src="https://unpkg.com/@coveops/taxonomy-breadcrumb@latest/dist/index.min.js"></script>
Disclaimer: Unpkg should be used for testing but not for production.
Using the Component
Install the component into your project.
npm i @coveops/taxonomy-breadcrumb
Use the Component or extend it:
Typescript
import { TaxonomyBreadcrumb, ITaxonomyBreadcrumbOptions } from '@coveops/taxonomy-breadcrumb';
Javascript
const TaxonomyBreadcrumb = require('@coveops/taxonomy-breadcrumb').TaxonomyBreadcrumb;
You can also expose the component alongside other components being built in your project.
export * from '@coveops/taxonomy-breadcrumb'
Include the component in your template as follows:
Place the component in your markup:
<div class="CoveoTaxonomyBreadcrumb" data-fields="@field1,@field2"></div>
Options
The following options can be configured:
| Option | Required | Type | Default | Notes |
| --- | --- | --- | --- | --- |
| fields
| Yes | IFieldOption[ ] | | The field(s) used to create the breadcrumb |
| separator
| No | string | >
| The separator inserted between field values in the breadcrumb |
| label
| No | string | empty string | This label is inserted in front of the breadcrumb. Can be styled using the .taxonomy-breadcrumb-label
CSS class. |
Extending
Extending the component can be done as follows:
import { TaxonomyBreadcrumb, ITaxonomyBreadcrumbOptions } from "@coveops/taxonomy-breadcrumb";
export interface IExtendedTaxonomyBreadcrumbOptions extends ITaxonomyBreadcrumbOptions {}
export class ExtendedTaxonomyBreadcrumb extends TaxonomyBreadcrumb {}
Contribute
- Clone the project
- Copy
.env.dist
to.env
and update the COVEO_ORG_ID and COVEO_TOKEN fields in the.env
file to use your Coveo credentials and SERVER_PORT to configure the port of the sandbox - it will use 8080 by default. - Build the code base:
npm run build
- Serve the sandbox for live development
npm run serve