lunr-store.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. var store = [
  2. {%- for c in site.collections -%}
  3. {%- if forloop.last -%}
  4. {%- assign l = true -%}
  5. {%- endif -%}
  6. {%- assign docs = c.docs | where_exp:'doc','doc.search != false' -%}
  7. {%- for doc in docs -%}
  8. {%- if doc.header.teaser -%}
  9. {%- capture teaser -%}{{ doc.header.teaser }}{%- endcapture -%}
  10. {%- else -%}
  11. {%- assign teaser = site.teaser -%}
  12. {%- endif -%}
  13. {
  14. "title": {{ doc.title | jsonify }},
  15. {% assign truncateWords=site.search_max_words_in_content %}
  16. "excerpt":
  17. {{ doc.content | newline_to_br |
  18. replace:"<br />", " " |
  19. replace:"</p>", " " |
  20. replace:"</h1>", " " |
  21. replace:"</h2>", " " |
  22. replace:"</h3>", " " |
  23. replace:"</h4>", " " |
  24. replace:"</h5>", " " |
  25. replace:"</h6>", " " |
  26. strip_html | strip_newlines | truncatewords: truncateWords | jsonify }},
  27. "categories": {{ doc.categories | jsonify }},
  28. "tags": {{ doc.tags | jsonify }},
  29. "url": {{ doc.url | absolute_url | jsonify }},
  30. "teaser":
  31. {%- if teaser contains "://" -%}
  32. {{ teaser | jsonify }}
  33. {%- else -%}
  34. {{ teaser | absolute_url | jsonify }}
  35. {%- endif -%}
  36. }{%- unless forloop.last and l -%},{%- endunless -%}
  37. {%- endfor -%}
  38. {%- endfor -%}]