UNPKG

cruk-searchkit

Version:

Set of overriden and new searchkit components designed specifically for Cancer Research UK

28 lines (23 loc) 606 B
import {HighlightAccessor} from 'searchkit'; import { zipObjectDeep } from 'lodash'; /** * Override highlight accessor to not squash objects. */ export default class CRUKSearchkitResultsHighlightAccessor extends HighlightAccessor { computeHighlightedFields(fields) { let highlightDefs = {}; fields.forEach(f => { if (typeof f === 'string') { highlightDefs[f] = {}; } if (typeof f === 'object') { let field = f.field delete f.field highlightDefs[field] = f; } }); return highlightDefs ? {fields: highlightDefs} : null; } }