Last active
July 5, 2016 13:45
-
-
Save rayrutjes/5a5954ca9c27cdcb47cc2cfb91c8daea to your computer and use it in GitHub Desktop.
Show relevant attribute instantsearch.js helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
search.templatesConfig.helpers.relevantContent = function() { | |
var attributes = ['content', 'title6', 'title5', 'title4', 'title3', 'title2', 'title1']; | |
var attribute_name; | |
for ( var index in attributes ) { | |
attribute_name = attributes[ index ]; | |
if ( this._highlightResult[ attribute_name ].matchedWords.length > 0 ) { | |
return this._snippetResult[ attribute_name ].value; | |
} | |
} | |
return this._snippetResult[ attributes[ 0 ] ].value; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment