Skip to content

Commit

Permalink
Fix: protect search-data.json file from front matter default for la…
Browse files Browse the repository at this point in the history
…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!
  • Loading branch information
mattxwang authored May 16, 2024
1 parent 1b79df8 commit 2dd535c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ This website is built from the `HEAD` of the `main` branch of the theme reposito
Code changes to `main` that are *not* in the latest release:

- Added: `nav_enabled` site, layout, and page-level variable to selectively show or hide the side/mobile menu by [@kevinlin1] in [#1441]. The minimal layout was reimplemented using this feature, and now has support for the site-wide search bar and auxiliary links.
- Fixed: protect `search-data.json` file from front matter default for layout by [@mattxwang] in [#1468]

Docs changes made since the latest release:

- Docs: Explained the `nav_enabled` variables as an alternative to using the minimal layout [@kevinlin1] in [#1441].

[#1468]: https://github.com/just-the-docs/just-the-docs/pull/1468

## Release v0.8.2

Hi everyone! This patch release fixes a bug where a default layout with unrestricted `scope` (`path: ""`) breaks JavaScript functionality. Users who do not use a default layout with unrestricted `scope` should not be affected. This should be a straightforward upgrade for all users. Thank you to [@pdmosses] for triaging and fixing the bug!
Expand Down
1 change: 1 addition & 0 deletions assets/js/zzzz-search-data.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
layout: null
permalink: /assets/js/search-data.json
---
{
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/search.rake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace :search do

File.open('assets/js/zzzz-search-data.json', 'w') do |f|
f.puts '---
layout: null
permalink: /assets/js/search-data.json
---
{
Expand Down

0 comments on commit 2dd535c

Please sign in to comment.