Skip to content

Commit 7e77bad

Browse files
committed
Fix search index generation
1 parent 90a3b83 commit 7e77bad

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

search.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
layout: null
3+
permalink: /search.json
4+
---
5+
[
6+
{% assign first = true %}
7+
{% assign home_page = site.pages | where: "url", "/" | first %}
8+
{% if home_page %}
9+
{% assign excerpt = home_page.content | markdownify | strip_html | strip_newlines | replace: " ", " " | strip | truncate: 2400, "" %}
10+
{
11+
"title": {{ home_page.title | default: site.title | strip_html | strip | jsonify }},
12+
"url": {{ home_page.url | relative_url | jsonify }},
13+
"content": {{ excerpt | jsonify }}
14+
}
15+
{% assign first = false %}
16+
{% endif %}
17+
{% assign static_pages = site.pages | sort: "url" %}
18+
{% for page in static_pages %}
19+
{% if page.title and page.url and page.url != "/" and page.url != "/search.json" %}
20+
{% unless first %},{% endunless %}
21+
{% assign excerpt = page.content | markdownify | strip_html | strip_newlines | replace: " ", " " | strip | truncate: 2400, "" %}
22+
{
23+
"title": {{ page.title | strip_html | strip | jsonify }},
24+
"url": {{ page.url | relative_url | jsonify }},
25+
"content": {{ excerpt | jsonify }}
26+
}
27+
{% assign first = false %}
28+
{% endif %}
29+
{% endfor %}
30+
{% assign documents = site.documents | sort: "url" %}
31+
{% for doc in documents %}
32+
{% if doc.output and doc.title and doc.url %}
33+
{% unless first %},{% endunless %}
34+
{% assign excerpt = doc.content | markdownify | strip_html | strip_newlines | replace: " ", " " | strip | truncate: 2400, "" %}
35+
{
36+
"title": {{ doc.title | strip_html | strip | jsonify }},
37+
"url": {{ doc.url | relative_url | jsonify }},
38+
"content": {{ excerpt | jsonify }}
39+
}
40+
{% assign first = false %}
41+
{% endif %}
42+
{% endfor %}
43+
]

0 commit comments

Comments
 (0)