--- regenerate: true --- {% capture cache %} {% comment %} # ----------------------------------------------------------------------------- # ~/assets/data/search.yml # Liquid YAML template to generate INDEX data used by SimpleJekyllSearch # # Product/Info: # http://jekyll.one # # Copyright (C) 2020 Juergen Adams # # J1 Template is licensed under the MIT License. # See: https://github.com/jekyll-one-org/J1 Template/blob/master/LICENSE # ----------------------------------------------------------------------------- # SimpleJekyllSearch, a JavaScript library to add search functionality # to any Jekyll Site or Blog. # # The Liquid template search.yml is used by J1 SimpleJekyllSearch. # This template is a helper that creates the search database (index, YAML) # for all documents. # # The Liquid template generates a simple YAML 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 YAML data created. Corrupted YAML data makes # the Javascript of SimpleJekyllSearch to fail (JSONLoader.js) and no # search functionality will be available for most UNCLEAR reasons. # ----------------------------------------------------------------------------- # NOTE: # Don't change the order of index generation (first pages, then posts). # This is because the helper 'forloop.last' is NOT usable as NO # 'site.pages.size' var is available. Instead, the pages array (site.pages) # is iterated. # ----------------------------------------------------------------------------- # NOTE: # For pages, NO excerpt is supported. As a replacement, the (page) # description is used. # ----------------------------------------------------------------------------- # Test data: # {{liquid_var|debug}} # ----------------------------------------------------------------------------- {% endcomment %} {% comment %} Set global settings -------------------------------------------------------------------------------- {% endcomment %} {% assign environment = site.environment %} {% assign template_version = site.version %} {% comment %} Process YML config data ================================================================================ {% endcomment %} {% comment %} Set config files -------------------------------------------------------------------------------- {% endcomment %} {% assign template_config = site.data.j1_config %} {% assign blocks = site.data.blocks %} {% assign modules = site.data.modules %} {% comment %} Set config data -------------------------------------------------------------------------------- {% endcomment %} {% assign jekyll_search_defaults = modules.defaults.jekyll_search.defaults %} {% assign jekyll_search_settings = modules.jekyll_search.settings %} {% comment %} Set config options -------------------------------------------------------------------------------- {% endcomment %} {% assign jekyll_search_options = jekyll_search_defaults|merge: jekyll_search_settings %} {% assign quick_search_config = site.data.modules.j1_jekyll_search %} {% comment %} Set config data -------------------------------------------------------------------------------- {% endcomment %} {% assign result_target = quick_search_config.target %} {% assign posts_num = site.posts.size %} {% assign production = false %} {% if environment == 'prod' or environment == 'production' %} {% assign production = true %} {% endif %} {% comment %} Process 'pages' FIRST -------------------------------------------------------------------------------- {% endcomment %} {% for page in site.pages %} {% if page.noindex %} {% continue %} {% endif %} {% if page.url contains 'assets' or page.url contains '.json' or page.url contains '.txt' %} {% continue %} {% endif %} {% if page.url contains '.html' %} {% continue %} {% endif %} {% if page.url == '/'%} {% continue %} {% endif %} { "title": "{{page.title|escape}}", "tagline": "{{page.tagline}}", "content": "page", {% 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 %} "date": "{{page.date}}", "url": "{{site.baseurl}}{{page.url}}", "target": "{{result_target}}", {% if page.excerpt %} "excerpt": "{{page.excerpt|newline_to_br|strip_html|strip|newline_to_space|replace:'"','\"'|truncatewords: jekyll_search_options.result_truncate|replace:'....','  ...'|replace:':...',' ...'}}" {% else %} "excerpt": "{{page.description|newline_to_br|strip_html|strip|newline_to_space|replace:'"','\"'|truncatewords: jekyll_search_options.result_truncate|replace:'....','  ...'|replace:':...',' ...'}}" {% endif %} }, {% endfor %} {% comment %} Process 'posts' -------------------------------------------------------------------------------- {% endcomment %} {% for post in site.posts %} {% if post.noindex %} {% continue %} {% endif %} { "title": "{{post.title|strip}}", "tagline": "{{post.tagline|strip}}", "content": "post", {% 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}}", {% if post.excerpt %} "excerpt": "{{post.excerpt|newline_to_br|strip_html|strip|newline_to_space| replace:'"','\"'|truncatewords: jekyll_search_options.result_truncate|replace:'....','  ...'|replace:':...','  ...'}}" {% else %} "excerpt": "" {% endif %} }{% if forloop.last %}{% else %},{% endif %} {% endfor %} {% endcapture %} [ {% if production %} {{cache|minifyJSON}} {% else %} {{cache|strip_empty_lines}} {% endif %} ] {% assign cache = nil %}