-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.json
36 lines (36 loc) · 1.65 KB
/
search.json
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
---
---
{% comment %}Generate json to be used for site search; currently only includes
volume pages and annotation content, but could be expanded to also include
other pages, e.g. introduction, credits, etc.{% endcomment %}
[
{% for page in site.volume_pages %}
{
"id" : {{forloop.index}},
"type" : "volume_page",
"title" : "{{ page.title | escape }}",
"url" : "{{ site.baseurl }}{{ page.url }}",
"page_url" : "{{ site.baseurl }}{{ page.url }}",
"image" : "{{ page.images.small-thumbnail}}",
"content" : {{ page.content | strip_html | strip_newlines | jsonify }},
"preview" : {{ page.content | strip_html | strip_newlines | truncatewords: 50 | jsonify}}
}{% unless forloop.last %},{% endunless %}
{% endfor %}
{% assign page_count = site.volume_pages|size %}
{% assign annotation_count = site.annotations|size %}
{% if page_count > 0 and annotation_count > 0 %}, {% endif %}
{% for annotation in site.annotations %}
{
"id" : {{forloop.index | plus: site.volume_pages.size}} ,
"type" : "annotation",
"tags" : {{ annotation.tags | jsonify }},
"content" : "{{ annotation.content | strip_html | strip_newlines }}",
"preview" : "{{ annotation.content | strip_html | strip_newlines | truncatewords: 50 }}",
{% assign page=site.volume_pages[annotation.page_index] %}
"title" : "Annotation of {{ page.title }}",
"url" : "{{ site.baseurl }}{{ annotation.url }}",
"page_url": "{{ site.baseurl }}{{ page.url }}",
"image" : "{{ page.images.small-thumbnail}}"
} {% unless forloop.last %},{% endunless %}
{% endfor %}
]