Repository navigation
fix: copy and list each site script only where pages load it - #526
Merged
Merged
Conversation
List the scripts and stylesheets Great Docs ships at the site root in `project.resources` in the order pages include them: marimo and lightbox files first, then `theme-init.js`, then the after-body scripts. The announcement, navbar style, content style and version selector scripts now appear in that order instead of being appended at the end. Only the order of `project.resources` changes. The set of listed files, the includes and the copied files remain unchanged.
One table describes every script and stylesheet Great Docs ships at the site root, in page load order. Each row specifies the file's gate, include list and any data entry that must precede it. Build preparation copies files from the table, `project.resources` lists them from it, and the header and after-body includes load them from it. Shared Quarto list operations convert a single value or a list into a list, find an entry by marker, add an include once or before an anchor, and add resources once. These operations replace the repeated normalise-and-append code in the moved blocks. The reference switcher inserts its script before `tooltips.js` instead of appending it. This preserves its position because the table now adds the later scripts earlier in the configuration pass. The table also lists resources previously listed by the announcement, navbar style, content style and marimo blocks. Copying, resource listing and includes retain separate gates. The GitHub widget, sidebar filter and dark-mode toggle scripts are still always copied and listed. The reference switcher is still always copied and never listed. The generated Quarto projects remain unchanged.
Each script and stylesheet has one gate for copying, `project.resources` and includes. Three scripts were copied into the build directory and listed as resources on every site, although pages loaded them only when their feature was enabled. `github-widget.js` is now copied and listed only when the site has a GitHub repository and uses the widget style. `sidebar-filter.js` is now copied and listed only when the sidebar filter is enabled. `dark-mode-toggle.js` is now copied and listed only when the dark-mode toggle is enabled. `reference-switcher.js` retains its previous treatment: it is copied when a CLI or MCP reference is configured and is never listed. Its inclusion in pages depends on the references the build generates, which the configuration alone cannot determine. Quarto project diff against the previous commit shows no changes to includes or filters. Among 40 default cases, `github-widget.js` is no longer copied or listed in 37 cases without a repository (36 builds and 1 watch), and `dark-mode-toggle.js` is no longer copied or listed in `gdtest_config_combo_f`. Among 15 further gate cases, copying and listing are removed for `github-widget.js` in 14 cases, `sidebar-filter.js` in 3 and `dark-mode-toggle.js` in 3.
📚 Preview this PR's docs locallyFetch the just-built site and open it in your browser: # this exact build
great-docs preview --run 41811002060
# or always the latest build for this PR
great-docs preview --pr 526Auth & tips
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Great Docs decided which of its site-root scripts a site gets in three separate lists: one for copying files into the build directory, one for
project.resourcesand one for the page includes. The lists disagreed, sogithub-widget.js,sidebar-filter.jsanddark-mode-toggle.jswere copied into every site and listed as resources even when no page loaded them. One table now drives all three, which also removes the repeated list-editing code from the Quarto configuration step.Sites without a GitHub repository, or with the sidebar filter or dark-mode toggle turned off, no longer publish those unused files, and
project.resourceslists the scripts in the order pages load them. What pages load, and in what order, does not change.