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

Search: results list doesn't display (Uncaught TypeError: e.tags.map is not a function) #3092

Closed
5 tasks done
Guts opened this issue Oct 8, 2021 · 8 comments
Closed
5 tasks done
Labels
documentation Issue concerns the documentation resolved Issue is resolved, yet unreleased if open

Comments

@Guts
Copy link
Contributor

Guts commented Oct 8, 2021

Contribution guidelines

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

  • ... the problem doesn't occur with the mkdocs or readthedocs themes
  • ... the problem persists when all overrides are removed, i.e. custom_dir, extra_javascript and extra_css
  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

Search behavior is broken in another fashion than #sear

Downstream issue: geotribu/website#435

Expected behaviour

Search normal behaviour, as described into the documentation or, at least, as for non insiders version.

Actual behaviour

When a user makes a search, the results list doesn't appears, but a console error does:

Capture d’écran de 2021-10-08 21-03-23

Steps to reproduce

  1. Install Insiders version > (or directly from the master branch: pip install -U git+https://github.com/squidfunk/mkdocs-material-insiders.git)
  2. Mkdocs serve
  3. search something into the search bar:
    • autocompletion: OK
    • share: OK
    • results count: OK
    • results list: KO
  4. Open the console and read the error:
Uncaught TypeError: e.tags.map is not a function
    Nr https://static.geotribu.fr/assets/javascripts/bundle.80a943f2.min.js:3
    ai https://static.geotribu.fr/assets/javascripts/bundle.80a943f2.min.js:3
    Fi https://static.geotribu.fr/assets/javascripts/bundle.80a943f2.min.js:3
    u https://static.geotribu.fr/assets/javascripts/bundle.80a943f2.min.js:3
    _next https://static.geotribu.fr/assets/javascripts/bundle.80a943f2.min.js:3
    next https://static.geotribu.fr/assets/javascripts/bundle.80a943f2.min.js:3
    n https://static.geotribu.fr/assets/javascripts/bundle.80a943f2.min.js:3
    _next https://static.geotribu.fr/assets/javascripts/bundle.80a943f2.min.js:3
    next https://static.geotribu.fr/assets/javascripts/bundle.80a943f2.min.js:3
    v https://static.geotribu.fr/assets/javascripts/bundle.80a943f2.min.js:3
    _next https://static.geotribu.fr/assets/javascripts/bundle.80a943f2.min.js:3

Package versions

  • Python: 3.8.10
  • MkDocs: 1.2.2
  • Material: Version: 7.3.2+insiders.3.1.2

Configuration

plugins:
  [...]
  - search
  [...]

System information

  • Operating system: Ubuntu LTS
  • Browser: Firefox 93, Chromium, Safari
@squidfunk
Copy link
Owner

squidfunk commented Oct 9, 2021

Thanks for reporting. I've looked at your website and you have a search_index.json, which is 41 MB in size (12 MB gzipped).

Observations

Tags syntax

I've also looked at the entries and most seem to be correct (they contain a lot of tags):

...
  {
      "location": "rdp/2021/rdp_2021-10-08/#30daymapchallenge-2021",
      "tags": [
        "30DayMapChallenge",
        "Centipede",
        "CNIG",
        "gouvernance",
        "GPS",
        "livre",
        "Mobilit\u00e9",
        "OpenStreetMap",
        "PostgreSQL",
        "QField",
        "QGIS",
        "QUADOGEO",
        "RTK"
      ],
      "text": "<p></p> <p>Topi Tjukanov lance le #30DayMapChallenge \u00e9dition 2021! Il s\u2019agit de r\u00e9aliser des rendus cartographiques quotidiens sur une p\u00e9riode d\u2019un mois. Ils devront \u00eatre cr\u00e9\u00e9s en suivant la liste de th\u00e8mes pr\u00e9-d\u00e9finie ci-dessous et devront \u00eatre partag\u00e9e sur Twitter en utilisant le hashtag : #30DayMapChallenge. Pour avoir un aper\u00e7u de ce qu\u2019\u00e0 pu faire notre camarade Aur\u00e9lien l\u2019an dernier, vous pouvez vous rendre sur sa page d\u00e9di\u00e9e.</p> <p>Pour ceux qui souhaiteraient suivre le d\u00e9fi sans cr\u00e9er de compte Twitter, vous pourrez simplement suivre le flux des publications par ici.</p> <p></p>",
      "title": "30DayMapChallenge 2021"
  },
...

However, some are broken – they must be defined as an array, not a list of comma-separated values, which is the source of the error you are seeing:

...
   {
      "location": "",
      "tags": "home,g\u00e9omatique,sig,g\u00e9ographie,dataviz,geordp,accueil,geotribu",
      "text": "<p>Bienvenue sur le site de Geotribu !</p> <p></p>",
      "title": "Bienvenue"
    }

Prebuilt index

You seem to be using the prebuild_index option which is deprecated and does not work with the new search. Thus, it must be switched off. If I remove the index field from the search_index.json, the index size drops to ~5 MB (1.7 MB gzipped), so by more than 80%.

Mitigations

  • Disable prebuild_index
  • Fix tags syntax

I'll add better error/warning messages when building the search_index, regarding both options.

@squidfunk squidfunk added documentation Issue concerns the documentation resolved Issue is resolved, yet unreleased if open labels Oct 9, 2021
@squidfunk
Copy link
Owner

84b49d9 adds warning messages and skips tags when the syntax is invalid (i.e., no list is given).:

WARNING  -  Material for MkDocs doesn't support the 'prebuild_index' option. Please remove it from 'mkdocs.yml'.
WARNING  -  Skipping 'tags' due to invalid syntax [creating-your-site.md]: foo, bar

@Guts
Copy link
Contributor Author

Guts commented Oct 11, 2021

Thank you for the detailed answer.

Disable prebuild_index

Indeed, it is related to the type of tag values. We're working on a complete overhaul ni a separate PR.

Question: why are the tags generated when the tags plugin is not enabled into the mkdocs.yml?

Disable prebuild_index

As for the pre-generated index, we had already deactivated it according to the recommendations in the doc.

@squidfunk
Copy link
Owner

Question: why are the tags generated when the tags plugin is not enabled into the mkdocs.yml?

I've not reached a final conclusion whether it makes sense or not to integrate tags inside search when the tags plugin is inactive, since tags indexing is subject to the search plugin, but I guess it makes more sense to omit tags when the plugin is not active. It's probably more what you'd expect. I'll add a patch for this later 😊

@Guts
Copy link
Contributor Author

Guts commented Oct 12, 2021

It's probably more what you'd expect. I'll add a patch for this later 😊

Indeed, we didn't expect to have to take care about our tags without the option enabled. In our mind: not explicitly enabled = disabled. Maybe we're too binary...

Thank you for your profesional and comprehensive work.

@Guts
Copy link
Contributor Author

Guts commented Oct 13, 2021

Just to follow up on this: we merged our tags clean-up and it works like a charm.

FYI, to value this work on tags, I've added support into the RSS plugin (as item categories): https://guts.github.io/mkdocs-rss-plugin/configuration/#item-categories

@squidfunk
Copy link
Owner

Really cool, awesome! I really need to activate the plugin for the new blog section in the docs.

@squidfunk
Copy link
Owner

57f5ac621 fixes the issue with tags being included in the search index, although the plugin was not switched on.

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

No branches or pull requests

2 participants