Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 for search/search_index.json if search plugin disabled #1877

Closed
4 tasks done
aimeos opened this issue Aug 22, 2020 · 3 comments
Closed
4 tasks done

404 for search/search_index.json if search plugin disabled #1877

aimeos opened this issue Aug 22, 2020 · 3 comments
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@aimeos
Copy link

aimeos commented Aug 22, 2020

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

  1. Set plugins: [] in the configuration
  2. Open the docs in the browser
  3. 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 %}
@squidfunk
Copy link
Owner

Thanks for reporting! That's indeed a bug. Thanks for providing a possible solution. Unfortunately, this will disable all other JavaScript-based features of the theme, but I'll look into it.

@squidfunk squidfunk added the bug Issue reports a bug label Aug 22, 2020
@squidfunk
Copy link
Owner

Fixed in 989b859 – easier than expected. The commit closed the issue, but I'll reopen it until it's released.

@squidfunk squidfunk reopened this Aug 22, 2020
@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Aug 22, 2020
@squidfunk
Copy link
Owner

Released as part of 5.5.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

2 participants