squidfunk / mkdocs-material

Documentation that simply works
https://squidfunk.github.io/mkdocs-material/
MIT License
20.69k stars 3.52k forks source link

localsearch fails to load after insiders v7 update to insiders v8 #3729

Closed shaneholloman closed 2 years ago

shaneholloman commented 2 years ago

Contribution guidelines

I've found a bug and checked that ...

Description

localsearch fails after update from v7 insiders to v8 Insiders https://github.com/squidfunk/mkdocs-material-insiders The search bar will not activate or give results

From Chrome Console:

shows: 8000/search/search_index.json:1 Failed to load resource: the server responded with a status of 404 (Not Found) However that's not true it is in fact here in the site build folder: /search/search_index.json

Uncaught ReferenceError: browser is not defined
    at onScriptLoad (adblock-onpage-icon-cs.js:172:3)
    at adblock-onpage-icon-cs.js:183:2
msgport.js:70 {"notify":"init_tab"}
:8000/search/search_index.json:1 Failed to load resource: the server responded with a status of 404 (Not Found)
api.github.com/repos/shaneholloman/resume/releases/latest:1 Failed to load resource: the server responded with a status of 404 ()
DevTools failed to load source map: Could not load content for http://127.0.0.1:8000/assets/js/mermaid.min.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE

Expected behaviour

Normally loads No additions or plugs made except the upgrade from v7 to v8

Actual behaviour

localsearch fails after update from v7 insiders to v8 Insiders https://github.com/squidfunk/mkdocs-material-insiders The search bar will not activate or give results

Steps to reproduce

  1. mkdocs build
  2. no errors during build
  3. load site
  4. search will no activate

Package versions

Configuration

No clue what constitutes minimal

---
copyright: Copyright © 2021 Shane Holloman
edit_uri: ""
extra:
  consent:
    title: Cookie consent
    description: >
      We use cookies to recognize your repeated visits and preferences, as well
      as to measure the effectiveness of our documentation and whether users
      find what they're searching for. With your consent, you're helping us to
      make our documentation better.
  social:
    - icon: fontawesome/brands/github
      link: https://github.com/shaneholloman/resume
    - icon: fontawesome/brands/twitter
      link: https://twitter.com/shaneholloman
    - icon: fontawesome/brands/linkedin
      link: https://linkedin.com/in/shaneholloman/
    - icon: fontawesome/brands/instagram
      link: https://instagram.com/shane.holloman.nz
extra_css:
  - assets/css/extra.css
  - assets/css/hint.min.css
extra_javascript:
  - assets/js/tablesort.min.js
  - assets/js/mermaid.min.js
  - assets/js/tables.js
markdown_extensions:
  - lightgallery:
      show_description_in_lightgallery: true
      show_description_as_inline_caption: true
  - abbr
  - admonition
  - attr_list
  - def_list
  - footnotes
  - mdx_spanner
  - md_in_html
  - meta
  - toc:
      permalink: ⚓︎
  - pymdownx.caret
  - pymdownx.critic
  - pymdownx.details
  - pymdownx.escapeall
  - pymdownx.highlight
  - pymdownx.inlinehilite
  - pymdownx.keys
  - pymdownx.mark
  - pymdownx.mark
  - pymdownx.smartsymbols
  - pymdownx.snippets:
      check_paths: true
  - pymdownx.superfences
  - pymdownx.tabbed
  - pymdownx.tilde
  - pymdownx.magiclink:
      repo: resume
      repo_url_shorthand: true
      user: shaneholloman
  - pymdownx.tasklist:
      clickable_checkbox: true
      custom_checkbox: true
  - pymdownx.betterem:
      smart_enable: all
  - pymdownx.highlight:
      linenums: true
  - pymdownx.emoji:
      emoji_index: !!python/name:materialx.emoji.twemoji
      emoji_generator: !!python/name:materialx.emoji.to_svg
      options:
        custom_icons:
          - overrides/.icons
plugins:
  - search
  - localsearch
  - tooltips
  - progress
  - redirects:
      redirect_maps: null
  - minify:
      minify_html: true
  #- enumerate-headings:
  #    toc_depth: 2
  #- git-revision-date-localized
  #- print-site
repo_name: github.com
repo_url: https://github.com/shaneholloman/resume
site_author: Shane Holloman
site_description: Kordia DevOps and Infrastructure
site_name: Kordia DevOps
site_url: null
theme:
  admonition:
    abstract: fontawesome/solid/book
    bug: fontawesome/solid/robot
    danger: fontawesome/solid/skull
    example: fontawesome/solid/flask
    failure: fontawesome/solid/bomb
    info: fontawesome/solid/info-circle
    note: fontawesome/solid/sticky-note
    question: fontawesome/solid/question-circle
    quote: fontawesome/solid/quote-left
    success: fontawesome/solid/check
    tip: fontawesome/solid/bullhorn
    warning: fontawesome/solid/exclamation-triangle
  custom_dir: theme
  features:
    - content.tabs.link
    - navigation.indexes
    - navigation.instant
    - navigation.top
    - navigation.tracking
    - search.highlight
    - search.share
    - search.suggest
    - content.code.annotate
  font:
    code: Roboto Mono
    text: Roboto
  icon:
    logo: kordia-icon #alien # material/alien
  favicon: assets/img/kordia-icon.svg
  language: en
  name: material
  palette:
    - accent: cyan
      primary: black
      scheme: default
      toggle:
        icon: material/toggle-switch-off-outline
        name: Switch to dark mode
    - accent: cyan
      primary: cyan
      scheme: slate
      toggle:
        icon: material/toggle-switch
        name: Switch to light mode
use_directory_urls: false

System information

Additional Info

theme/main.html

{% extends "base.html" %}

{% block config %} {{ super() }} {% if "localsearch"
in config["plugins"] %}
<script src="{{ 'assets/js/iframe-worker.js' | url }}"></script>
<script src="{{ 'search/search_index.js' | url }}"></script>
{% endif %} {% endblock %}

{% block styles %}
    {{ super() }}
    <link rel="stylesheet" href="{{ base_url }}/css/lightgallery.min.css">
{% endblock styles %}

{% block libs %}
    {{ super() }}
    <script src="{{ base_url }}/js/lightgallery.min.js"></script>
{% endblock libs %}

{% block scripts %}
    {{ super() }}
    <script>
    var elements = document.getElementsByClassName("lightgallery");
    for(var i=0; i<elements.length; i++) {
       lightGallery(elements[i]);
    }
    </script>
{% endblock scripts %}
lampensau commented 2 years ago

Not certain, but I believe your problem is caused by the localsearch plugin as offline search has been introduced with version 4.7.0 as an addtion to mkdocs-material-insiders itself.

As the documentation currently only mentions localsearch for non-insider versions I'd assume that you no longer need it if using mkdocs-material-insiders.

shaneholloman commented 2 years ago

you are correct @lampensau Here's the solve: https://github.com/wilhelmer/mkdocs-localsearch/issues/19#issuecomment-1068987196

squidfunk commented 2 years ago

Thanks @wilhelmer and @lampensau for solving this! The brand new Offline plugin supersedes localsearch.