Skip to content

Conversation

@biplavbarua
Copy link

Formalize book.js Patching

Description

This PR formalizes the process of patching book.js.

Previously, theme/book.js contained custom modifications (Google Analytics) but there was no clear separation from the upstream mdBook code, and third_party/mdbook/book.js was a symlink to this modified file.

This change:

  1. Restores third_party/mdbook/book.js to its pristine upstream state (matching mdBook version used).
  2. Adds a patches/book.js.patch file containing the custom Google Analytics integration.
  3. Adds a new xtask patch-assets command to automatically apply this patch.
  4. Updates xtask install-tools to run patch-assets, ensuring the environment is always correctly set up.

Verification

  • Run cargo xtask patch-assets to verify the patch applies cleanly.
  • Inspect theme/book.js to confirm gtag calls are present.
  • Run cargo xtask serve to verify the book builds and serves correctly.

Fixes #2924

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.

Formalize patching of book.js

1 participant