Skip to content

fix: copy and list each site script only where pages load it - #526

Merged
has2k1 merged 3 commits into
mainfrom
refactor/script-table
Nov 4, 2026
Merged

has2k1 merged 3 commits into
mainfrom
refactor/script-table

Conversation

@has2k1

@has2k1 has2k1 commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

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.resources and one for the page includes. The lists disagreed, so github-widget.js, sidebar-filter.js and dark-mode-toggle.js were 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.resources lists the scripts in the order pages load them. What pages load, and in what order, does not change.

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.
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

📚 Preview this PR's docs locally

Fetch 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 526
Auth & tips
  • Requires great-docs: pip install great-docs (or run via pipx/uvx).
  • Auth: run gh auth login then add --use-gh, or set GITHUB_TOKEN (needs Actions: read).
  • Jump to a page: add --path reference/index.html.
  • Latest vs exact: --pr <n> grabs the newest build; --run <id> pins this one.
  • Re-download: --refresh ignores the local cache.

@has2k1
has2k1 merged commit 8c8c220 into main Nov 4, 2026
9 checks passed
@has2k1
has2k1 deleted the refactor/script-table branch November 4, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant