From 9056b925c5a34b1ab73123799bd6050178f8bc35 Mon Sep 17 00:00:00 2001 From: Tao He Date: Tue, 9 May 2023 15:58:54 +0800 Subject: [PATCH] Add highlight for search terms Signed-off-by: Tao He --- docs/_templates/base.html | 14 +++++++++----- docs/_templates/search.html | 5 +++++ 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 docs/_templates/search.html diff --git a/docs/_templates/base.html b/docs/_templates/base.html index 3693d21208e4..9f3e340172d6 100644 --- a/docs/_templates/base.html +++ b/docs/_templates/base.html @@ -48,9 +48,10 @@ src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"> - - - + {% endblock %} {% block body %} @@ -75,8 +76,11 @@ } ready(function() { - let searchindexjs = document.getElementById("searchindexjs"); - searchindexjs.src = "{{ pathto('searchindex.js', 1) }}"; + // preload searchindex.js + let script = document.createElement("script"); + script.src = "{{ pathto('searchindex.js', 1) }}"; + script.type = "text/javascript"; + document.getElementsByTagName("head")[0].appendChild(script); }); {% endblock %} diff --git a/docs/_templates/search.html b/docs/_templates/search.html new file mode 100644 index 000000000000..2707aa759fec --- /dev/null +++ b/docs/_templates/search.html @@ -0,0 +1,5 @@ +{% extends "!search.html" %} + +{%- block regular_scripts -%} +{{ super() }} +{%- endblock regular_scripts-%}