Components Snippet

Edit this page

Snippet

Safely display snippeted attributes of your search results.

This component leverages the snippeting feature of Algolia but adds some sugar on top of it to prevent XSS attacks.

Usage

Basic usage:

<ais-snippet :result="result" attribute-name="description"></ais-snippet>

Access a nested property:

Given an record like:

{
    "objectID": 1,
    "meta": {
        "title": "my title"
    }
}

You can access the snippeted version by specifying the path by separating levels with dots:

<ais-snippet :result="result" attribute-name="meta.title"></ais-snippet>

Props

Name Required Type Default Description
result true Object A single Algolia result as it is returned by the API.
attribute-name true String The attribute name to be snippeted.

CSS Classes

ClassName Description
ais-snippet Container class