Skip to content

Commit fa86b78

Browse files
committed
clean up search data, add authors to it
1 parent 5908608 commit fa86b78

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

assets/js/zzzz-search-data.json

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,26 @@ permalink: /assets/js/search-data.json
1515
{%- endif -%}
1616
{%- endfor -%}
1717
{%- endif -%}
18-
{%- assign liquid_regex = "{" | append: "{.+?}" | append: "}|{" | append: "%.+?%" | append: "}" -%}
1918
{%- for pages in pages_array -%}
2019
{%- for page in pages -%}
2120
{%- if page.title and page.search_exclude != true -%}
2221
{%- assign page_content = page.content -%}
23-
{%- if page.collection == "mods" -%}
24-
{%- assign page_content = page_content | strip | default: page.pyproject.project.description -%}
22+
{%- if page.collection contains "_mods" -%}
23+
{%- assign page_content = page_content | strip -%}
24+
{%- if page_content == "" -%}
25+
{%- assign page_content = page.pyproject.project.description | markdownify -%}
26+
{%- endif -%}
27+
28+
{%- assign pyproject_authors = page.pyproject.project.authors
29+
| map: "name"
30+
| array_to_sentence_string -%}
31+
{%- assign mod_authors = page.author
32+
| default: pyproject_authors
33+
| escape
34+
| prepend: "By: "
35+
| append: " . " -%}
36+
{%- assign page_content = page_content | prepend: mod_authors -%}
2537
{%- endif -%}
26-
{%- assign page_content = page_content | markdownify | regex_replace: liquid_regex, '' -%}
2738
{%- assign heading_level = site.search.heading_level | default: 2 -%}
2839
{%- for j in (2..heading_level) -%}
2940
{%- assign tag = '<h' | append: j -%}
@@ -51,29 +62,27 @@ permalink: /assets/js/search-data.json
5162
{%- endif -%}
5263
{%- endif -%}
5364
{%- unless i == 0 -%},{%- endunless -%}
54-
"{{ i }}": {
55-
"doc": {{ page.title | jsonify }},
56-
"title": {{ title | jsonify }},
57-
"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 }},
58-
"url": "{{ url | relative_url }}",
59-
{% include lunr/custom-data.json page=page %}
60-
"relUrl": "{{ url }}"
61-
}
65+
{{-""-}} "{{ i }}":{
66+
{{-""-}} "doc":{{ page.title | jsonify }},
67+
{{-""-}} "title":{{ title | jsonify }},
68+
{{-""-}} "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 }},
69+
{{-""-}} "url":"{{ url | relative_url }}",
70+
{{-""-}} "relUrl":"{{ url }}"
71+
{{-""-}} }
6272
{%- assign i = i | plus: 1 -%}
6373
{%- endfor -%}
6474
{%- unless title_found -%}
6575
{%- unless i == 0 -%},{%- endunless -%}
66-
"{{ i }}": {
67-
"doc": {{ page.title | jsonify }},
68-
"title": {{ page.title | jsonify }},
69-
"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 }},
70-
"url": "{{ page.url | relative_url }}",
71-
{% include lunr/custom-data.json page=page %}
72-
"relUrl": "{{ page.url }}"
73-
}
76+
{{-""-}} "{{ i }}":{
77+
{{-""-}} "doc":{{ page.title | jsonify }},
78+
{{-""-}} "title":{{ page.title | jsonify }},
79+
{{-""-}} "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 }},
80+
{{-""-}} "url":"{{ page.url | relative_url }}",
81+
{{-""-}} "relUrl":"{{ page.url }}"
82+
{{-""-}} }
7483
{%- assign i = i | plus: 1 -%}
7584
{%- endunless -%}
7685
{%- endif -%}
7786
{%- endfor -%}
78-
{%- endfor %}
87+
{%- endfor -%}
7988
}

0 commit comments

Comments
 (0)