Migrating custom search worker from 8.5.11 to 9.5.33 #8343
-
Hi! When migrating mkdocs-material to version 9.5.33 we realized that custom search worker integration process has changed. In older version, we used the following construction to do that {% extends "base.html" %}
{% block config %}
{{ super() }}
<script>
var __search = {
worker: "/assets/js/generated/search/worker.js"
}
</script>
{% endblock %} Alas, it doesn't work that way in newer versions. So, how do I solve this issue? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
Hi @threadedstream, There is a dangling dead URL here: And the search URL is taken from the config object, which is passed in the mkdocs-material/src/templates/base.html Line 420 in b2d235e I don't know what's the purpose of the worker, nor what's the API, what data needs to be passed over etc. You don't have to write it in TypeScript, but perhaps it would be easier, I'm not sure TBH. Or maybe I'm missing something. |
Beta Was this translation helpful? Give feedback.
-
Oh, I see it now. Well, does it mean we should abandon the idea of overriding search worker altogether? |
Beta Was this translation helpful? Give feedback.
-
@squidfunk @kamilkrzyskow I'm sorry for reopening the discussion once again. I wonder if it's possible to develop my own search plugin, that would coexist with mkdocs-material and use all its perks like styles, themes, icons, etc, but at the same time have the ability to overwrite the worker behaviour. We really need to upgrade to newer mkdocs-material because version 8.5.11 has vulnerabilities and security guys are pushing us to perform upgrade. I actually tried to develop my own plugin by modifying search.html a little bit and embedding it via header.html, basically I tried to put search functionality of 8.5.11 into 9.5.33. Unfortunately, it didn't work, because material overwrites everything and renders its own htmls. |
Beta Was this translation helpful? Give feedback.
Hi @threadedstream,
I didn't even know that there was a support for a custom worker in the past 🤔
Looking at the source code, the idea has been mostly abandoned. [EDIT: So custom hooks, aren't supported anymore like I assumed, but the rest of the answer is still valid in saying you can overwrite the current worker with your own]
There is a dangling dead URL here:
mkdocs-material/src/templates/assets/javascripts/integrations/search/worker/_/index.ts
Line 63 in b2d235e
And the search URL is taken from the config object, which is passed in the
base.html
template:mkdocs-material/src/templates/assets/javascri…