From 2dd535c2dad2ccb78775805e339f8d73edfbd416 Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Wed, 15 May 2024 17:06:27 -0700 Subject: [PATCH] Fix: protect `search-data.json` file from front matter default for layout (#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! --- CHANGELOG.md | 3 +++ assets/js/zzzz-search-data.json | 1 + lib/tasks/search.rake | 1 + 3 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93cba94..487c18c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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! diff --git a/assets/js/zzzz-search-data.json b/assets/js/zzzz-search-data.json index 370dbe5..a04b791 100644 --- a/assets/js/zzzz-search-data.json +++ b/assets/js/zzzz-search-data.json @@ -1,4 +1,5 @@ --- +layout: null permalink: /assets/js/search-data.json --- { diff --git a/lib/tasks/search.rake b/lib/tasks/search.rake index d1f9fd4..38b3717 100644 --- a/lib/tasks/search.rake +++ b/lib/tasks/search.rake @@ -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 --- {