Skip to content

Commit 9224ab5

Browse files
indexing headings for algolia
1 parent 62053a2 commit 9224ab5

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ algolia:
7777
application_id : DTC6BXXR43
7878
index_name : # YOUR_INDEX_NAME
7979
search_only_api_key : 4177df0cc4b2523ee42d6992389ecaf4
80+
nodes_to_index: 'p, h1, h2, h3, h4' # Index paragraphs and headings
8081
powered_by : # true (default), false
8182
google:
8283
search_engine_id : # YOUR_SEARCH_ENGINE_ID

_includes/search/algolia-search-scripts.html

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,17 @@
2424
}
2525
});
2626

27-
const hitTemplate = function(hit) {
28-
const url = hit.url;
29-
const hightlight = hit._highlightResult;
30-
const title = hightlight.title && hightlight.title.value || "";
31-
const content = hightlight.html && hightlight.html.value || "";
32-
33-
return `
34-
<div class="list__item">
35-
<article class="archive__item" itemscope itemtype="https://schema.org/CreativeWork">
36-
<h2 class="archive__item-title" itemprop="headline"><a href="{{ site.baseurl }}${url}">${title}</a></h2>
37-
<div class="archive__item-excerpt" itemprop="description">${content}</div>
38-
</article>
39-
</div>
40-
`;
41-
}
27+
const hitTemplate = (hit) => {
28+
return `
29+
<div class="list__item">
30+
<article class="archive__item">
31+
<h2 class="archive__item-title">
32+
<a href="${hit.url}">${hit.title}</a>
33+
</h2>
34+
<div class="archive__item-excerpt">${hit._highlightResult.content.value}</div>
35+
</article>
36+
</div>`;
37+
};
4238

4339
// Adding searchbar and results widgets
4440
search.addWidget(

_sass/minimal-mistakes.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use "custom";
12
/* Copyright comment */
23
@import "minimal-mistakes/copyright";
34

@@ -35,3 +36,4 @@
3536
@import "minimal-mistakes/archive";
3637
@import "minimal-mistakes/sidebar";
3738
@import "minimal-mistakes/print";
39+

0 commit comments

Comments
 (0)