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