--- regenerate: false --- {% comment %} # ----------------------------------------------------------------------------- # ~/assets/data/search.json # Liquid JSON template to generate ALL data used by SimpleJekyllSearch # # Product/Info: # http://jekyll.one # # Copyright (C) 2019 Juergen Adams # # J1 Template is licensed under the MIT License. # See: https://github.com/jekyll-one/j1_template_mde/blob/master/LICENSE # # ----------------------------------------------------------------------------- # # The Liquid template search.json is used by J1 SimpleJekyllSearch. # This template is a helper that creates the search database (JSON) # for all documets. # SimpleJekyllSearch, a JavaScript library to add search functionality # to any Jekyll Site or Blog. This template is a helper to generate # the corresponding search index data file search.json within the # site generated by Jekyll. # # The Liquid generates a JSON file as an array that contains objects for all # posts and pages included for indexing. See below the fields taken from the # source files. # # NOTE: # Be careful changing the Liquid code. If the code is changed, check # the integrity of the JSON data created. Corrupted JSON data makes # the Javascript of an Adapter to fail and no functionality will # be available for most UNCLEAR reasons. # # ----------------------------------------------------------------------------- # Test data: # {{ liquid_var | debug }} # ----------------------------------------------------------------------------- {% endcomment %} {% capture cache %} {% assign quick_search_config = site.data.modules.j1_jekyll_search %} {% assign result_target = quick_search_config.target %} {% for post in site.posts %} {% unless post.noindex %} { "title": "{{ post.title | strip }}", "tagline": "{{ post.tagline | strip }}", {% if post.excerpt %} "excerpt": "{{ post.excerpt | newline_to_br | strip_html | strip | newline_to_space | replace:'"','\"' | truncatewords: 100 }}", {% else %} "excerpt": "", {% endif %} {% if post.tags %} "tags": "{{ post.tags | join: ',' }}", {% else %} "tags": "", {% endif %} {% if post.index %} "index": "{{ post.index | join: ',' }}", {% else %} "index": "", {% endif %} {% if post.categories %} "categories": "{{ post.categories | join: ',' }}", {% else %} "categories": "", {% endif %} "date": "{{ post.date }}", "url": "{{ site.baseurl }}{{ post.url }}", "target": "{{ result_target }}" }, {% endunless %} {% endfor %} {% for page in site.pages %} {% unless page.noindex %} {% unless page.url contains 'assets' or page.url contains '.json' or page.url contains '.txt' or page.url == '/'%} { "title": "{{ page.title | escape }}", "tagline": "{{ page.tagline }}", {% if page.tags %} "tags": "{{ page.tags | join: ', ' }}", {% else %} "tags": "", {% endif %} {% if page.index %} "index": "{{ page.index | join: ', ' }}", {% else %} "index": "", {% endif %} {% if page.categories %} "categories": "{{ page.categories | join: ', ' }}", {% else %} "categories": "", {% endif %} "url": "{{ site.baseurl }}{{ page.url }}", "target": "{{ result_target }}" }, {% endunless %} {% endunless %} {% endfor %} {} {% endcapture %} [ {{ cache | strip_empty_lines }} ] {% assign cache = nil %}