Skip to content

Commit

Permalink
docs(js): document highlighting utils
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Sep 9, 2020
1 parent 00e2227 commit f97a0fb
Show file tree
Hide file tree
Showing 5 changed files with 213 additions and 1 deletion.
51 changes: 51 additions & 0 deletions packages/website/docs/highlightItem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
id: highlightItem
---

Returns a string with highlighted and escaped matching parts of an Algolia hit.

# Example

```js
import { highlightItem } from '@algolia/autocomplete-js';

const item = {}; // fetch an Algolia hit
const highlightedValue = highlightItem({
item,
attribute: 'query',
});
```

# Reference

## Params

### `item`

> `AlgoliaHit` | required
The Algolia hit to retrieve the attribute value from.

### `attribute`

> `string` | required
The attribute to retrieve the highlight value from.

### `highlightPreTag`

> `string` | defaults to `<mark>`
The HTML tag to prefix the value with.

### `highlightPostTag`

> `string` | defaults to `</mark>`
The HTML tag to suffix the value with.

### `ignoreEscape`

> `string[]` | defaults to `[]`
The characters to skip from escaping.
51 changes: 51 additions & 0 deletions packages/website/docs/reverseHighlightItem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
id: reverseHighlightItem
---

Returns a string with highlighted and escaped non-matching parts of an Algolia hit.

# Example

```js
import { reverseHighlightItem } from '@algolia/autocomplete-js';

const item = {}; // fetch an Algolia hit
const highlightedValue = reverseHighlightItem({
item,
attribute: 'query',
});
```

# Reference

## Params

### `item`

> `AlgoliaHit` | required
The Algolia hit to retrieve the attribute value from.

### `attribute`

> `string` | required
The attribute to retrieve the highlight value from.

### `highlightPreTag`

> `string` | defaults to `<mark>`
The HTML tag to prefix the value with.

### `highlightPostTag`

> `string` | defaults to `</mark>`
The HTML tag to suffix the value with.

### `ignoreEscape`

> `string[]` | defaults to `[]`
The characters to skip from escaping.
51 changes: 51 additions & 0 deletions packages/website/docs/reverseSnippetItem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
id: reverseSnippetItem
---

Returns a string with highlighted and escaped non-matching parts of an Algolia hit snippet.

# Example

```js
import { reverseSnippetItem } from '@algolia/autocomplete-js';

const item = {}; // fetch an Algolia hit
const reverseSnippetedValue = reverseSnippetItem({
item,
attribute: 'query',
});
```

# Reference

## Params

### `item`

> `AlgoliaHit` | required
The Algolia hit to retrieve the attribute value from.

### `attribute`

> `string` | required
The attribute to retrieve the snippet value from.

### `highlightPreTag`

> `string` | defaults to `<mark>`
The HTML tag to prefix the value with.

### `highlightPostTag`

> `string` | defaults to `</mark>`
The HTML tag to suffix the value with.

### `ignoreEscape`

> `string[]` | defaults to `[]`
The characters to skip from escaping.
51 changes: 51 additions & 0 deletions packages/website/docs/snippetItem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
id: snippetItem
---

Returns a string with highlighted and escaped matching parts of an Algolia hit snippet.

# Example

```js
import { snippetItem } from '@algolia/autocomplete-js';

const item = {}; // fetch an Algolia hit
const snippetedValue = snippetItem({
item,
attribute: 'query',
});
```

# Reference

## Params

### `item`

> `AlgoliaHit` | required
The Algolia hit to retrieve the attribute value from.

### `attribute`

> `string` | required
The attribute to retrieve the snippet value from.

### `highlightPreTag`

> `string` | defaults to `<mark>`
The HTML tag to prefix the value with.

### `highlightPostTag`

> `string` | defaults to `</mark>`
The HTML tag to suffix the value with.

### `ignoreEscape`

> `string[]` | defaults to `[]`
The characters to skip from escaping.
10 changes: 9 additions & 1 deletion packages/website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ module.exports = {
{
type: 'category',
label: 'autocomplete-js',
items: ['autocomplete-js', 'getAlgoliaHits-js', 'getAlgoliaResults-js'],
items: [
'autocomplete-js',
'getAlgoliaHits-js',
'getAlgoliaResults-js',
'highlightItem',
'reverseHighlightItem',
'snippetItem',
'reverseSnippetItem',
],
},
{
type: 'category',
Expand Down

0 comments on commit f97a0fb

Please sign in to comment.