-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Labels
bugIssue reports a bugIssue reports a bugresolvedIssue is resolved, yet unreleased if openIssue is resolved, yet unreleased if open
Description
I checked that...
- ... the documentation does not mention anything about my problem
- ... the problem doesn't occur with the default MkDocs template
- ... the problem is not in any of my customizations (CSS, JS, template)
- ... there are no open or closed issues that are related to my problem
Description
The service worker of the "search" plugin is executed even if the plugin is disabled using plugins: []
in the configuration. Thus, the service worker requests a none existing /search/search_index.json
and a 404 is retured by the web server.
Expected behavior
The service worker isn't initialized if set plugins: []
in the configuration.
Actual behavior
Initialization is done unconditionally in the base.html
file of the theme.
Steps to reproduce the bug
- Set
plugins: []
in the configuration - Open the docs in the browser
- In the browser console, an error about the missing
search/search_index.json
file is logged
Package versions
- Python:
Python 3.6.9
- MkDocs:
mkdocs, version 1.1.2
- Material:
Version: 4.5.0
Project configuration
plugins: []
Possible solution
Check if search plugin is enabled in base.html
:
{% if 'search' in plugins %}
<script>
app = initialize({
base: "{{ base_url }}",
features: {{ config.theme.features | tojson }},
search: Object.assign({
worker: "{{ 'assets/javascripts/worker/search.a68abb33.min.js' | url }}"
}, typeof search !== "undefined" && search)
})
</script>
{% endif %}
Metadata
Metadata
Assignees
Labels
bugIssue reports a bugIssue reports a bugresolvedIssue is resolved, yet unreleased if openIssue is resolved, yet unreleased if open