From 9c0d836408af2e72dbce115a01ce6627137e66dd Mon Sep 17 00:00:00 2001 From: Dale Phurrough Date: Mon, 19 Dec 2022 01:58:28 +0100 Subject: [PATCH] use custom JTD theme with custom search indexing --- Gemfile | 2 +- Gemfile.lock | 6 +++--- docs/_includes/lunr-data.json | 30 ++++++++++++++++++++++++++++ docs/_includes/lunr-index.js | 3 +++ docs/assets/js/zzzz-search-data.json | 2 ++ 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 docs/_includes/lunr-data.json create mode 100644 docs/_includes/lunr-index.js diff --git a/Gemfile b/Gemfile index 837f788..5859a1b 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index b04d6e4..7467938 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/docs/_includes/lunr-data.json b/docs/_includes/lunr-data.json new file mode 100644 index 0000000..3060234 --- /dev/null +++ b/docs/_includes/lunr-data.json @@ -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 -%} \ No newline at end of file diff --git a/docs/_includes/lunr-index.js b/docs/_includes/lunr-index.js new file mode 100644 index 0000000..277b303 --- /dev/null +++ b/docs/_includes/lunr-index.js @@ -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(' '); diff --git a/docs/assets/js/zzzz-search-data.json b/docs/assets/js/zzzz-search-data.json index 74dd0ba..19e534b 100644 --- a/docs/assets/js/zzzz-search-data.json +++ b/docs/assets/js/zzzz-search-data.json @@ -51,6 +51,7 @@ permalink: /assets/js/search-data.json "title": {{ title | jsonify }}, "content": {{ content | replace: '