-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 functionality is not working out of the box, zzzz-search-data.json is getting rendered as a HTML page instead of a JSON file #1466
Labels
Comments
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:
defaults:
- scope:
path: ""
values:
layout: "default" So, your suggested solution should resolve this problem; I will use |
No worries, glad to know it helped! |
mattxwang
added a commit
that referenced
this issue
May 16, 2024
…yout (#1468) Fixes #1466. Prior art: #1447. Otherwise self-explanatory. To test: 1. First, clone [template repository](https://github.com/just-the-docs/just-the-docs-template/tree/main). Observe that search works. 2. Next, add a default layout to all files ```yml defaults: - scope: path: "" values: layout: "default" ``` 3. Observe that search no longer works. 4. Apply this patch 5. Observe that search works again!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The text was updated successfully, but these errors were encountered: