Closed 5hwb closed 5 months ago
Hi @5hwb, thank you for submitting an issue! I appreciate your in-depth steps to reproduce this problem - and it makes complete sense (we just fixed a similar issue in #1447). In particular, a concise reproduction pattern is:
_config.yml
:defaults:
- scope:
path: ""
values:
layout: "default"
So, your suggested solution should resolve this problem; I will use layout: null
(as explained in #1447). I'll submit a PR shortly. Thanks!
No worries, glad to know it helped!
Describe the bug
When creating a Jekyll site and adding on the just-the-docs theme later on, the search functionality does not work, generating no output. Further investigation revealed that the search data JSON file (assets/js/zzzz-search-data.json) was being treated by the template engine as a HTML page and applying the associated HTML markup and styling to the entire file, causing the JSON to become unparsable and preventing Lunr.js from successfully starting.
Opening up the browser dev tools reveals an error
Uncaught SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
.There is a simple workaround which involves setting the layout to
none
in the front matter of assets/js/zzzz-search-data.json, preventing the template engine from rendering the JSON as a HTML page. Open assets/js/zzzz-search-data.json and replace the front matter:with the following:
To Reproduce Steps to reproduce the behavior:
gem "just-the-docs", "~> 0.8.2"
, the latest version as of 24 Apr 2024, then runbundle install
search_enabled = true
in the project config at _config.ymlbundle exec just-the-docs rake search:init
bundle exec jekyll serve
Expected behavior Search results should appear when typing in the search bar.
Screenshots If applicable, add screenshots to help explain your problem.
Out of the box: Search functionality not working
What should happen: Search results show up after typing in search bar
Desktop (please complete the following information):
Additional context
Ruby version is 3.3.0 and was installed via the asdf version management tool.