mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 05:13:33 -06:00
add options for custom lunr
Liquid and JS code (#1068)
This is a prototype for review and discussion. My use and testing of this PR is on top of6d9d41359c
. The changes are trival to rebase to `main` and I'm happy to do so if this prototype moves forward. * Feature request details in linked issue, fixes just-the-docs/just-the-docs#1067 * I welcome feedback and all discussion * A draft doc site of mine using this PR is at https://docs.hidale.com/ To use the prototype, the two include files need to be customized. Here are mine from the draft website9c0d836408
Co-authored-by: Matt Wang <matt@matthewwang.me>
This commit is contained in:
@@ -87,6 +87,7 @@ function initSearch() {
|
||||
this.metadataWhitelist = ['position']
|
||||
|
||||
for (var i in docs) {
|
||||
{% include lunr/custom-index.js %}
|
||||
this.add({
|
||||
id: i,
|
||||
title: docs[i].title,
|
||||
|
@@ -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/custom-data.json page=page %}
|
||||
"relUrl": "{{ url }}"
|
||||
}
|
||||
{%- assign i = i | plus: 1 -%}
|
||||
@@ -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/custom-data.json page=page %}
|
||||
"relUrl": "{{ page.url }}"
|
||||
}
|
||||
{%- assign i = i | plus: 1 -%}
|
||||
|
Reference in New Issue
Block a user