Skip to content

Commit

Permalink
Generate the search JSON (god I hate Jekyll 😭)
Browse files Browse the repository at this point in the history
  • Loading branch information
noirbizarre committed Dec 5, 2018
1 parent b8638d3 commit 7e6a55a
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions search.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
layout: null
---
[
{% assign counter = 0 %}
{%- for post in site.posts -%}
{%- if post.title != nil -%}{% assign counter = counter | plus:1 %}
"title" : "{{ post.title | escape }}",
"category" : "{{ post.category }}",
"tags" : "{{ post.tags | join: ', ' }}",
"url" : "{{ site.baseurl }}{{ post.url }}",
"date" : "{{ post.date }}",
"content" : {{ post.content | strip_html | replace: "\n", " " | jsonify }}
} {% unless forloop.last %},{% endunless %}
{%- endif -%}
{%- endfor -%}
{%- if counter > 0 -%},{% assign counter = 0 %}{%- endif -%}

{%- for page in site.pages -%}
{%- if page.title != nil -%}{% assign counter = counter | plus:1 %}
{
"title" : "{{ page.title | escape }}",
"category" : "{{ page.category }}",
"tags" : "{{ page.tags | join: ', ' }}",
"url" : "{{ site.baseurl }}{{ page.url }}",
"date" : "{{ page.date }}",
"content" : {{ page.content | strip_html | replace: "\n", " " | jsonify }}
}{% unless forloop.last %},{% endunless %}
{%- endif -%}
{%- endfor -%}
{%- if counter > 0 -%},{% assign counter = 0 %}{%- endif -%}

{%- for collection in site.collections -%}
{%- if collection.docs.size > 0 -%}
{%- for page in collection.docs -%}{% assign counter = counter | plus:1 %}
{
"title" : "{{ page.title | escape }}",
"category" : "{{ page.category }}",
"tags" : "{{ page.tags | join: ', ' }}",
"url" : "{{ site.baseurl }}{{ page.url }}",
"date" : "{{ page.date }}",
"content" : {{ page.content | strip_html | replace: "\n", " " | jsonify }}
}{% unless forloop.last %},{% endunless %}
{%- endfor -%}
{%- endif -%}
{% unless forloop.last %}{%- if counter > 0 -%},{% assign counter = 0 %}{%- endif -%}{% endunless %}
{%- endfor -%}
]

0 comments on commit 7e6a55a

Please sign in to comment.