|
| 1 | +--- |
| 2 | +permalink: /assets/js/search-data.json |
| 3 | +--- |
| 4 | +{ |
| 5 | + {%- assign i = 0 -%} |
| 6 | + {% for page in site.html_pages %} |
| 7 | + {%- if page.title and page.search_exclude != true -%} |
| 8 | + {%- assign page_content = page.content -%} |
| 9 | + {%- assign heading_level = site.search.heading_level | default: 2 -%} |
| 10 | + {%- for j in (2..heading_level) -%} |
| 11 | + {%- assign tag = '<h' | append: j -%} |
| 12 | + {%- assign closing_tag = '</h' | append: j -%} |
| 13 | + {%- assign page_content = page_content | replace: tag, '<h1' | replace: closing_tag, '</h1' -%} |
| 14 | + {%- endfor -%} |
| 15 | + {%- assign parts = page_content | split: '<h1' -%} |
| 16 | + {%- assign title_found = false -%} |
| 17 | + {% for part in parts offset: 1 %} |
| 18 | + {%- assign titleAndContent = part | split: '</h1>' -%} |
| 19 | + {%- assign title = titleAndContent[0] | replace_first: '>', '<h1>' | split: '<h1>' -%} |
| 20 | + {%- assign title = title[1] | strip_html -%} |
| 21 | + {%- assign content = titleAndContent[1] -%} |
| 22 | + {%- assign url = page.url -%} |
| 23 | + {%- if title == page.title and parts[0] == '' -%} |
| 24 | + {%- assign title_found = true -%} |
| 25 | + {%- else -%} |
| 26 | + {%- assign id = titleAndContent[0] -%} |
| 27 | + {%- assign id = id | split: 'id="' -%} |
| 28 | + {%- if id.size == 2 -%} |
| 29 | + {%- assign id = id[1] -%} |
| 30 | + {%- assign id = id | split: '"' -%} |
| 31 | + {%- assign id = id[0] -%} |
| 32 | + {%- capture url -%}{{ url | append: '#' | append: id }}{%- endcapture -%} |
| 33 | + {%- endif -%} |
| 34 | + {%- endif -%} |
| 35 | + {%- unless i == 0 -%},{%- endunless -%} |
| 36 | + "{{ i }}": { |
| 37 | + "doc": {{ page.title | jsonify }}, |
| 38 | + "title": {{ title | jsonify }}, |
| 39 | + "content": {{ content | replace: '</h', ' . </h' | replace: '<hr', ' . <hr' | replace: '</p', ' . </p' | replace: '<ul', ' . <ul' | replace: '</ul', ' . </ul' | replace: '<ol', ' . <ol' | replace: '</ol', ' . </ol' | replace: '</tr', ' . </tr' | replace: '<li', ' | <li' | replace: '</li', ' | </li' | replace: '</td', ' | </td' | replace: '<td', ' | <td' | replace: '</th', ' | </th' | replace: '<th', ' | <th' | strip_html | remove: 'Table of contents' | normalize_whitespace | replace: '. . .', '.' | replace: '. .', '.' | replace: '| |', '|' | append: ' ' | jsonify }}, |
| 40 | + "url": "{{ url | absolute_url }}", |
| 41 | + "relUrl": "{{ url }}" |
| 42 | + } |
| 43 | + {%- assign i = i | plus: 1 -%} |
| 44 | + {%- endfor -%} |
| 45 | + {%- unless title_found -%} |
| 46 | + {%- unless i == 0 -%},{%- endunless -%} |
| 47 | + "{{ i }}": { |
| 48 | + "doc": {{ page.title | jsonify }}, |
| 49 | + "title": {{ page.title | jsonify }}, |
| 50 | + "content": {{ parts[0] | replace: '</h', ' . </h' | replace: '<hr', ' . <hr' | replace: '</p', ' . </p' | replace: '<ul', ' . <ul' | replace: '</ul', ' . </ul' | replace: '<ol', ' . <ol' | replace: '</ol', ' . </ol' | replace: '</tr', ' . </tr' | replace: '<li', ' | <li' | replace: '</li', ' | </li' | replace: '</td', ' | </td' | replace: '<td', ' | <td' | replace: '</th', ' | </th' | replace: '<th', ' | <th' | strip_html | remove: 'Table of contents' | normalize_whitespace | replace: '. . .', '.' | replace: '. .', '.' | replace: '| |', '|' | append: ' ' | jsonify }}, |
| 51 | + "url": "{{ page.url | absolute_url }}", |
| 52 | + "relUrl": "{{ page.url }}" |
| 53 | + } |
| 54 | + {%- assign i = i | plus: 1 -%} |
| 55 | + {%- endunless -%} |
| 56 | + {%- endif -%} |
| 57 | + {% endfor %} |
| 58 | +} |
0 commit comments