fix: resolve incorrect URLs for pre-quiz tests missing /academy prefix#191
fix: resolve incorrect URLs for pre-quiz tests missing /academy prefix#191AnkitRewar11 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request modifies layouts/test/single.html to update how Hugo variables are injected into JavaScript, specifically adding quotes to testId and build and replacing client-side path logic for curriculaRoot with Hugo's .RelPermalink. Feedback recommends using the jsonify filter for these injections to provide safer character escaping and more robust integration within the JavaScript context.
Signed-off-by: ankitrewar11 <ankitrewar11@gmail.com>
8e58fd5 to
6208dfb
Compare
|
🚀 Preview deployment: https://layer5io.github.io/academy-theme/pr-preview/pr-191/ |
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect pre-quiz redirect URLs that were missing the /academy prefix by removing brittle runtime path slicing and using Hugo-provided permalinks at build time.
Changes:
- Serialize
testIdandbuildinto JavaScript usingjsonifyto ensure valid JS values. - Replace
window.location.pathnamesegment slicing with{{ .RelPermalink | strings.TrimSuffix "/" }}(viajsonify) to build correct redirect roots under/academy.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Notes for Reviewers
This PR fixes #127
What was the problem?
Pre-quiz test URLs were missing the
/academyprefix.The
curriculaRootvariable was built using hardcoded.slice(0, 5)onwindow.location.pathnameat runtime, which generated incorrect URLslike
/learning-paths/xxxinstead of/academy/learning-paths/xxx.What was changed?
File:
layouts/test/single.htmlReplaced the hardcoded JavaScript path-splitting logic:
With Hugo's
RelPermalinkwhich injects the correct full path at build time:Why this fix?
Hugo's
.RelPermalinkcorrectly includes the/academybase path prefixat build time — no runtime path manipulation needed.
Signed commits