Skip to content

Commit 918a256

Browse files
committed
Exclude file for algolia indexing, update hit template
1 parent c3a8f00 commit 918a256

File tree

2 files changed

+39
-29
lines changed

2 files changed

+39
-29
lines changed

_config.yml

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ algolia:
4040
application_id: GVFM3KX3UX
4141
index_name: rnehra01.github.io
4242
search_only_api_key: 4f0ffe8c2149d573ab7f386921c55713
43+
files_to_exclude: [
44+
index.html,
45+
about/index.md
46+
]
4347
settings:
4448
attributesToSnippet: ['*:33']
4549
highlightPreTag: '<em class="ais-match-highlight">'

_includes/algolia.html

+35-29
Original file line numberDiff line numberDiff line change
@@ -23,59 +23,65 @@
2323

2424
const hitTemplate = function(hit){
2525
let isCover = hit.cover;
26-
let articleClass = "post-card";
26+
let articleClass = "post-card home-template";
2727
if(!isCover) articleClass += " no-image";
2828

2929
const title = hit._highlightResult.title.value;
3030
const content = hit._highlightResult.html.value;
3131
console.log(hit._highlightResult);
3232
let template = `<article class="${articleClass}">`
3333
if(isCover){
34-
template += ` <a class="post-card-image-link" href="{{ site.baseurl }}${hit.url.substring(1)}">
35-
<div class="post-card-image" style="background-image: url({{ site.baseurl }}${ hit.cover })"></div>
36-
</a>`;
34+
template += `
35+
<a class="post-card-image-link" href="{{ site.baseurl }}${hit.url.substring(1)}">
36+
<div class="post-card-image" style="background-image: url({{ site.baseurl }}${ hit.cover })"></div>
37+
</a>`;
3738
}
38-
39-
template += `<div class="post-card-content">
40-
<div class="post-card-content-link">
41-
<header class="post-card-header">`;
39+
40+
template += `
41+
<div class="post-card-content">
42+
<div class="post-card-content-link">
43+
<header class="post-card-header">`;
4244

4345
let date = '';
4446
if (hit.date) {
45-
date = moment.unix(hit.date).format('MMM D, YYYY');
46-
template += `<time class="post-card-tags-date" datetime="{{ page.date | date:'%e %B %Y' }}">${date}</time>`;
47+
date = moment.unix(hit.date).format('D MMMM YYYY');
48+
template += `
49+
<time class="post-card-tags-date" datetime="{{ page.date | date:'%e %B %Y' }}">${date}</time>`;
4750
}
48-
51+
4952
if('tags' in hit && hit.tags.length){
50-
template += `<span class="post-card-tags-date">/</span>`;
53+
template += `
54+
<span class="post-card-tags-date">/</span>`;
5155
for(tag_index in hit.tags){
5256
if(tag_index == hit.tags.length-1)
53-
template += `<a class="post-card-tags-date" href='{{ site.baseurl }}tag/${hit.tags[tag_index]}/'>${hit.tags[tag_index]}</a>`;
57+
template += `
58+
<a class="post-card-tags-date" href='{{ site.baseurl }}tag/${hit.tags[tag_index]}/'>${hit.tags[tag_index]}</a>`;
5459
else
55-
template += `<a class="post-card-tags-date" href='{{ site.baseurl }}tag/${hit.tags[tag_index]}/'>${hit.tags[tag_index]},</a>`;
56-
60+
template += `
61+
<a class="post-card-tags-date" href='{{ site.baseurl }}tag/${hit.tags[tag_index]}/'>${hit.tags[tag_index]},</a>`;
5762
}
5863
}
5964

60-
template += `</header>
61-
<header class="post-card-header">
62-
<h2 class="post-card-title">${ title }</h2>
63-
</header>
64-
<section class="post-card-excerpt">
65-
<p>${ content }...</p>
66-
</section>
67-
</div>
68-
<footer class="post-card-meta">
69-
</footer>
70-
</div>
71-
</article>`;
65+
template += `
66+
</header>
67+
<header class="post-card-header">
68+
<h2 class="post-card-title">${ title }</h2>
69+
</header>
70+
<section class="post-card-excerpt">
71+
${ content }
72+
</section>
73+
</div>
74+
<footer class="post-card-meta">
75+
</footer>
76+
</div>
77+
</article>`;
7278

7379
return template;
7480
};
75-
81+
7682
search.addWidget(
7783
instantsearch.widgets.hits({
78-
container: '#search-hits',
84+
container: '#search-hits',
7985
templates: {
8086
item: hitTemplate,
8187
empty: function(data){

0 commit comments

Comments
 (0)