search_plus_index.json 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. ---
  2. # Content index for gitbook-plugin-search-pro
  3. layout: null
  4. ---
  5. {%- assign index = "" | split: "" -%}
  6. {%- assign excluded_files = site.gitbook_search.exclude.files -%}
  7. {%- assign excluded_tags = site.gitbook_search.exclude.tags | uniq -%}
  8. {%- assign excluded_categories = site.gitbook_search.exclude.categories | uniq -%}
  9. {%- assign excluded_taxonomies = excluded_tags | concat: excluded_categories | uniq -%}
  10. {%- for collection in site.collections -%}
  11. {%- if collection.output -%}
  12. {%- for post in site[collection.label] -%}
  13. {%- unless post.exclude_from_search == true or excluded_files contains post.path -%}
  14. {%- assign has_excluded_taxonomy = false -%}
  15. {%- for tag in post.tags -%}
  16. {%- if excluded_taxonomies contains tag -%}
  17. {%- assign has_excluded_taxonomy = true -%}
  18. {%- endif -%}
  19. {%- endfor -%}
  20. {%- for category in post.categories -%}
  21. {%- if excluded_taxonomies contains category -%}
  22. {%- assign has_excluded_taxonomy = true -%}
  23. {%- endif -%}
  24. {%- endfor -%}
  25. {%- unless has_excluded_taxonomy == true -%}
  26. {%- assign index = index | push: post | uniq -%}
  27. {%- endunless -%}
  28. {%- endunless -%}
  29. {%- endfor -%}
  30. {%- endif -%}
  31. {%- endfor -%}
  32. {%- if site.gitbook_search.include.pages == true -%}
  33. {%- for page in site.html_pages -%}
  34. {%- unless page.exclude_from_search == true or excluded_files contains page.path -%}
  35. {%- assign has_excluded_taxonomy = false -%}
  36. {%- for tag in page.tags -%}
  37. {%- if excluded_taxonomies contains tag -%}
  38. {%- assign has_excluded_taxonomy = true -%}
  39. {%- endif -%}
  40. {%- endfor -%}
  41. {%- for category in page.categories -%}
  42. {%- if excluded_taxonomies contains category -%}
  43. {%- assign has_excluded_taxonomy = true -%}
  44. {%- endif -%}
  45. {%- endfor -%}
  46. {%- unless has_excluded_taxonomy == true -%}
  47. {%- assign index = index | push: page | uniq -%}
  48. {%- endunless -%}
  49. {%- endunless -%}
  50. {%- endfor -%}
  51. {%- endif -%}
  52. {%- for collection in site.gitbook_search.include.collections -%}
  53. {%- assign documents = site.documents | where:"collection",collection -%}
  54. {%- for document in documents -%}
  55. {%- unless document.exclude_from_search == true or excluded_files contains document.path -%}
  56. {%- assign has_excluded_taxonomy = false -%}
  57. {%- for tag in document.tags -%}
  58. {%- if excluded_taxonomies contains tag -%}
  59. {%- assign has_excluded_taxonomy = true -%}
  60. {%- endif -%}
  61. {%- endfor -%}
  62. {%- for category in document.categories -%}
  63. {%- if excluded_taxonomies contains category -%}
  64. {%- assign has_excluded_taxonomy = true -%}
  65. {%- endif -%}
  66. {%- endfor -%}
  67. {%- unless has_excluded_taxonomy == true -%}
  68. {%- assign index = index | push: document | uniq -%}
  69. {%- endunless -%}
  70. {%- endunless -%}
  71. {%- endfor -%}
  72. {%- endfor -%}
  73. {
  74. {%- for document in index -%}
  75. {%- assign tags = document.tags | uniq -%}
  76. {%- assign categories = document.categories | uniq -%}
  77. {%- assign taxonomies = tags | concat: categories | uniq -%}
  78. {{ document.url | relative_url | jsonify }}: {
  79. "title": {{ document.title | smartify | strip_html | normalize_whitespace | jsonify }},
  80. "keywords": {{ taxonomies | join: " " | normalize_whitespace | jsonify }},
  81. "url": {{ document.url | relative_url | jsonify }},
  82. "body": {{ document.content | strip_html | normalize_whitespace | jsonify }}
  83. }{%- unless forloop.last -%},{%- endunless -%}
  84. {%- endfor -%}
  85. }