From ab67a96fc0aa8351a78ad702882bef095602ba59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Chalifour?= Date: Mon, 26 Oct 2020 11:49:39 +0100 Subject: [PATCH] feat: rename `item` to `hit` in highlight utils --- examples/js/app.ts | 6 +++--- packages/autocomplete-js/src/highlight.ts | 24 +++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/js/app.ts b/examples/js/app.ts index a36b36d73..d021723f3 100644 --- a/examples/js/app.ts +++ b/examples/js/app.ts @@ -4,7 +4,7 @@ import { autocomplete, AutocompleteSource, getAlgoliaHits, - reverseHighlightItem, + reverseHighlightHit, } from '@algolia/autocomplete-js'; import { createRecentSearchesPlugin } from '@algolia/autocomplete-plugin-recent-searches'; import '@algolia/autocomplete-plugin-recent-searches/style'; @@ -51,8 +51,8 @@ autocomplete>({ return `
${searchIcon}
- ${reverseHighlightItem({ - item, + ${reverseHighlightHit({ + hit: item, attribute: 'query', })}
diff --git a/packages/autocomplete-js/src/highlight.ts b/packages/autocomplete-js/src/highlight.ts index 449223fb8..fbe0bbcc2 100644 --- a/packages/autocomplete-js/src/highlight.ts +++ b/packages/autocomplete-js/src/highlight.ts @@ -36,8 +36,8 @@ type HighlightItemParams = { /** * Highlights and escapes the matching parts of an Algolia hit. */ -export function highlightItem>({ - item, +export function highlightHit>({ + item: hit, attribute, highlightPreTag = '', highlightPostTag = '', @@ -45,7 +45,7 @@ export function highlightItem>({ }: HighlightItemParams) { return concatParts( parseAlgoliaHitHighlight({ - hit: item, + hit, attribute, ignoreEscape, }), @@ -58,8 +58,8 @@ export function highlightItem>({ * * This is a common pattern for Query Suggestions. */ -export function reverseHighlightItem>({ - item, +export function reverseHighlightHit>({ + item: hit, attribute, highlightPreTag = '', highlightPostTag = '', @@ -67,7 +67,7 @@ export function reverseHighlightItem>({ }: HighlightItemParams) { return concatParts( parseAlgoliaHitReverseHighlight({ - hit: item, + hit, attribute, ignoreEscape, }), @@ -78,8 +78,8 @@ export function reverseHighlightItem>({ /** * Highlights and escapes the matching parts of an Algolia hit snippet. */ -export function snippetItem>({ - item, +export function snippetHit>({ + item: hit, attribute, highlightPreTag = '', highlightPostTag = '', @@ -87,7 +87,7 @@ export function snippetItem>({ }: HighlightItemParams) { return concatParts( parseAlgoliaHitSnippet({ - hit: item, + hit, attribute, ignoreEscape, }), @@ -100,8 +100,8 @@ export function snippetItem>({ * * This is a common pattern for Query Suggestions. */ -export function reverseSnippetItem>({ - item, +export function reverseSnippetHit>({ + item: hit, attribute, highlightPreTag = '', highlightPostTag = '', @@ -109,7 +109,7 @@ export function reverseSnippetItem>({ }: HighlightItemParams) { return concatParts( parseAlgoliaHitReverseSnippet({ - hit: item, + hit, attribute, ignoreEscape, }),