Skip to content

Commit

Permalink
use custom JTD theme with custom search indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
diablodale committed Dec 19, 2022
1 parent 1628f9c commit 9c0d836
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ gem "jekyll", "~> 4.3" # installed by `gem jekyll`

# gem "just-the-docs", "0.4.0.rc3" # currently the latest pre-release
# BUGBUG below is fix for dup external links https://github.com/just-the-docs/just-the-docs/issues/1062
gem "just-the-docs", github: "just-the-docs/just-the-docs", ref: "6d9d41359c46882d9b64a446d5a83fac5b3e20a7"
gem "just-the-docs", github: "diablodale/just-the-docs", branch: "dp-release"

# If you have any plugins, put them here!
group :jekyll_plugins do
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GIT
remote: https://github.com/just-the-docs/just-the-docs.git
revision: 6d9d41359c46882d9b64a446d5a83fac5b3e20a7
ref: 6d9d41359c46882d9b64a446d5a83fac5b3e20a7
remote: https://github.com/diablodale/just-the-docs.git
revision: 9d861f167aa3f633473f8ea66de6c9a779539df0
branch: dp-release
specs:
just-the-docs (0.4.0.rc3)
jekyll (>= 3.8.5)
Expand Down
30 changes: 30 additions & 0 deletions docs/_includes/lunr-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{%- if include.page.usage -%}

{%- capture newline %}
{% endcapture -%}

{%- if include.page.usage.values -%}

{%- if include.page.usage.values.first -%}
{%- capture flat_content -%}
{%- for value in include.page.usage.values -%}
{{ value[0] }}
{{ value[1] }}
{% endfor -%}
{%- endcapture -%}
{%- else -%}
{% assign flat_content = include.page.usage.values %}
{%- endif -%}
"uvalues": "{{ flat_content | markdownify | replace:newline,' ' | strip_html | normalize_whitespace | strip }}",
{%- endif -%}

{%- if include.page.usage.examples -%}
{%- capture flat_content -%}
{%- for example in include.page.usage.examples -%}
{{ example }}
{% endfor -%}
{%- endcapture %}
"uexamples": "{{ flat_content | markdownify | replace:newline,' ' | strip_html | normalize_whitespace | strip }}",
{%- endif -%}

{%- endif -%}
3 changes: 3 additions & 0 deletions docs/_includes/lunr-index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// docs[i] is current entry within assets/js/search-data.json
const content_to_merge = [docs[i].content, docs[i].uvalues, docs[i].uexamples];
docs[i].content = content_to_merge.join(' ');
2 changes: 2 additions & 0 deletions docs/assets/js/zzzz-search-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ permalink: /assets/js/search-data.json
"title": {{ title | jsonify }},
"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 }},
"url": "{{ url | relative_url }}",
{% include lunr-data.json page=page %}
"relUrl": "{{ url }}"
}
{%- assign i = i | plus: 1 -%}
Expand All @@ -62,6 +63,7 @@ permalink: /assets/js/search-data.json
"title": {{ page.title | jsonify }},
"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 }},
"url": "{{ page.url | relative_url }}",
{% include lunr-data.json page=page %}
"relUrl": "{{ page.url }}"
}
{%- assign i = i | plus: 1 -%}
Expand Down

0 comments on commit 9c0d836

Please sign in to comment.