Files
bqkc/assets/js/lunr-store.js
Nasir Anthony Montalvo 526096840e Initial commit
2025-11-13 14:48:58 -06:00

19 lines
808 B
JavaScript

---
# create lunr store for search page
---
{% if site.data.theme.search-child-objects == true %}
{%- assign items = site.data[site.metadata] | where_exp: 'item','item.objectid' -%}
{% else %}
{%- assign items = site.data[site.metadata] | where_exp: 'item','item.objectid and item.parentid == nil' -%}
{% endif %}
{%- assign fields = site.data.config-search -%}
var store = [
{%- for item in items -%}
{
{% for f in fields %}{% if item[f.field] %}{{ f.field | jsonify }}: {{ item[f.field] | normalize_whitespace | replace: '""','"' | jsonify }},{% endif %}{% endfor %}
"id": {% if item.parentid %}{{ item.parentid | append: '.html#' | append: item.objectid | jsonify }}{% else %}{{item.objectid | append: '.html' | jsonify }}{% endif %}
}{%- unless forloop.last -%},{%- endunless -%}
{%- endfor -%}
];