mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-05-07 18:18:42 -05:00
[PR #1622] [MERGED] fix(dev): rewrite shared navbar URLs by page depth in dev preview #9228
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/harvard-edge/cs249r_book/pull/1622
Author: @farhan523
Created: 5/1/2026
Status: ✅ Merged
Merged: 5/1/2026
Merged by: @profvjreddi
Base:
dev← Head:fix/dev-navbar-rewrite-nested-paths📝 Commits (1)
b251b6afix(dev): rewrite navbar URLs by page depth📊 Changes
1 file changed (+42 additions, -17 deletions)
View changed files
📝
.github/scripts/rewrite-dev-urls.sh(+42 -17)📄 Description
Summary
Issue
The shared navbar uses absolute production URLs like
https://mlsysbook.ai/labs/andhttps://mlsysbook.ai/kits/. In dev preview,.github/scripts/rewrite-dev-urls.shrewrites those URLs forhttps://harvard-edge.github.io/cs249r_book_dev/.The bug was that the rewrite script used one static
../prefix per subsite. That worked for top-level pages likekits/index.html, but it broke on nested pages like:kits/contents/arduino/nicla_vision/image_classification/image_classification.htmlFrom a deep page, navbar links like
Labswere rewritten too shallowly and resolved under the current chapter path, producing broken URLs like:https://harvard-edge.github.io/cs249r_book_dev/kits/contents/arduino/nicla_vision/labs/Why Local Worked
Local Quarto preview serves the site in project context, so this post-build dev rewrite mismatch does not show up there.
The published dev site is different: it rewrites production URLs after render so each subsite lives under
cs249r_book_dev/. That rewrite logic was where the bug lived.Fix
Update
.github/scripts/rewrite-dev-urls.shto compute prefixes per rendered HTML file:Test Plan
Script verification
https://mlsysbook.ai/labs/,https://mlsysbook.ai/kits/, andhttps://mlsysbook.ai/contents/arduino/nicla_vision/image_classification/with the same linksbash .github/scripts/rewrite-dev-urls.sh kits tmp/rewrite-verify../labs/,./, and../../../../../../labs/,../../../../, and../../../../../Manual dev-preview verification
https://harvard-edge.github.io/cs249r_book_dev/kits/contents/arduino/nicla_vision/image_classification/image_classification.htmlBuild -> LabsBuild -> Hardware KitsAboutorCommunitycs249r_book_dev/<subsite>/...path rather than under the current chapter directoryRegression checks
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.