forked from sujaykundu777/devlopr-jekyll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
algolia_search.html
66 lines (55 loc) · 1.87 KB
/
algolia_search.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<style>
#search-searchbar{
width: 100%;
text-align: center;
margin-top: 20px;
}
.ais-search-box {
margin-top: 15px;
margin-bottom: 15px;
}
.ais-hits--item{
float:left;
}
#search-container{
width: 100%;
}
</style>
<script>
/* Instanciating InstantSearch.js with Algolia credentials */
const search = instantsearch({
appId: '{{ site.algolia.application_id }}',
indexName: '{{ site.algolia.index_name }}',
apiKey: '{{ site.algolia.search_only_api_key }}'
});
search.addWidget(
instantsearch.widgets.searchBox({
container: '#search-searchbar',
placeholder: 'Search into posts...',
poweredBy: true
})
);
search.addWidget(
instantsearch.widgets.hits({
container: '#search-hits',
templates: {
item: function(hit) {
return `
<div class="card blog-post">
<img class="card-img-top" src="${ hit.thumbnail }" alt="${ hit.title }">
<div class="card-body center">
<img src="{{site.url}}{{site.baseurl}}/assets/img/{{ site.author_logo }}" class="author-profile-img">
<h4 class="card-title">${ hit.title }</h4>
<h6 class="card-subtitle mb-2 text-muted">${moment.unix(hit.date).format('MMM D, YYYY')}</h6>
<p class="card-text">${hit.summary }</p>
<a href="${hit.url}" data-disqus-identifier="${hit.url}" class="btn btn-primary btn-sm">Read</a>
<span class="disqus-comment-count" data-disqus-identifier="${ hit.url }"></span>
</div>
</div>
`;
}
}
})
);
search.start();
</script>