addsearch-search-ui
Version:
JavaScript library to develop Search UIs for the web
50 lines (42 loc) • 1.77 kB
JavaScript
// If you are customising the default search result template, make sure your links still include the data-analytics-click="{{id}}" attribute,
// otherwise your analytics will not report clicks or CTR correctly.
export const SEARCHRESULTS_TEMPLATE = `
<div class="addsearch-searchresults">
{{
{{> numberOfResultsTemplate }}
{{/if}}
{{
<div class="hit{{#equals type "PROMOTED"}} promoted{{/equals}}">
<h3>
<a href="{{url}}" data-analytics-click="{{id}}">{{
</h3>
<div class="highlight">
{{> searchResultImageTemplate}}
{{{highlight}}}{{
</div>
{{
<div class="category">
{{selectCategory ..}}
</div>
{{/gt}}
</div>
{{/each}}
</div>
`;
export const SEARCHRESULT_IMAGE_TEMPLATE = `
<span class="main-image {{document_type}} {{#unless images.main}}noimage{{/unless}}"{{
{{
{{else if style.image_url}}<img src="{{style.image_url}}" alt="{{title}}" />{{/if}}
</span>
`;
export const NUMBER_OF_RESULTS_TEMPLATE = `
<div class="number-of-results">
{{
{{total_hits}}{{
</div>
`;
export const NO_RESULTS_TEMPLATE = `
<div class="addsearch-searchresults addsearch-searchresults-no-results">
<h2>No search results with keyword <em>{{keyword}}</em></h2>
</div>
`;