-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathlunr.liquid
28 lines (27 loc) · 892 Bytes
/
lunr.liquid
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
---
permalink: /js/lunr_docs.json
title: lunr index
data:
comment: creates a document collection for lunr to index (site search)
---
{% assign idx = 0 %}
{% assign post_count = collections.posts.pages | size %}
[
{% for post in collections.posts.pages %}
{% assign idx = idx | plus: 1 %}
{
"title" : "{{ post.title }}",
{% assign tags_list = post.data.tags | replace: " ", "" | split: "," %}
{% assign tags_size = tags_list | size | minus: 1 %}
{% assign idx2 = 0 %}
"tags": [
{% for tag in tags_list %}
"{{ tag }}"{% if idx2 < tags_size %},{% endif %}
{% assign idx2 = idx2 | plus: 1 %}
{% endfor %}
],
"href" : "{{ post.permalink }}",
"content" : "{{ post.content | strip_html | strip_newlines | replace: "\", "\\" }}"
}{% if idx < post_count %},{% endif %}
{% endfor %}
]