Repository navigation
Accept a lowercase region in language codes (pt-br) when expanding shorthand doc paths - #823
Merged
Merged
Conversation
The `reroute` hook expands shorthand doc URLs to the full route, and its
language matcher only accepted `xx` or `xx-XX`. A code like `pt-br` fails
that test, so the language segment is never shifted off the path and ends
up in the chapter id, while `_lang` falls back to the current language and
still satisfies the equality checks:
/docs/smol-course/pr_306/pt-br/unit1/1
-> /docs/smol-course/pr_306/pt-br/pt-br/unit1/1 (404)
SvelteKit applies `reroute` during prerendering too, so every page of such
a language 404s and the build aborts on the first one. Before the kit
upgrade to Svelte 5 (#792) this logic lived in a fork of SvelteKit's
client and never ran at build time.
huggingface/smol-course is the only repo in the org with a lowercase
region (`pt-br`); `zh-CN`, `ru-RU` and `pt-BR` already matched.
Verified by building `smol-course/units/pt-br` with `--html`: 14 pages
404 and the build exits 1 before the change, and it exits 0 with all 14
HTML files after it. Building `units/ko` still passes.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
What does this PR do?
Fixes the doc build for repos whose language code has a lowercase region, broken since the kit upgrade to Svelte 5 (#792). Today that is huggingface/smol-course (
pt-br), where every PR doc build fails.getHfDocFullPath($lib/hfDocPaths.js) expands shorthand doc URLs to the full route, and its language matcher is/^[a-z]{2}(-[A-Z]{2})?$/.pt-brfails that test, so the language segment is never shifted offparamsand ends up inside the chapter id, while_langfalls back to__DOCS_LANGUAGE__and still satisfies the equality checks below:That function is the
reroutehook, and SvelteKit applies it while prerendering too, so every page of the language 404s and the build aborts on the first one. Before #792 this logic lived in thesvelteKitCustomClientfork of SvelteKit's client, which only ran in the browser, so the build never saw it.zh-CN(agents-course, course, cookbook),ru-RU(agents-course) andpt-BR(audio-transformers-course) already matched.pt-brin smol-course is the only code in the org that does not.Changes:
/^[a-z]{2}(-[A-Za-z]{2})?$/.Verified by building
smol-course/units/pt-brlocally with--html:which reproduces the CI failure of huggingface/smol-course#306 line for line. Building
units/kostill passes (exit 0, 8 HTML files), and I checked the reroute mapping foren,zh-CN,ru-RU,pt-BRandpt-br, plus the shorthand (/docs/lib/page) and other-language (returnsundefined) paths.kit/has no JS test runner, so there is no unit test to add here without pulling in one.Once merged, re-running the smol-course checks should go green with no smol-course-side change (the reusable PR-doc workflow checks out doc-builder from
main).🤖 Generated with Claude Code