fix(docs): preserve #anchor when rewriting sibling links for Docusaurus#5963
Merged
Conversation
rewriteSiblingLinks matched the whole link against the known-slug set, so `node-metrics#air-quality-metrics` never matched and kept its bare slug. Docusaurus then resolved it as a sub-path of the current page, breaking the meshtastic.org docs build (onBrokenLinks: throw). Split off a trailing #anchor / ?query before the slug lookups and re-append it after inserting .md, so `node-metrics#air-quality-metrics` → `node-metrics.md#air-quality-metrics`. Covers index, cross-section, and sibling link forms. Co-Authored-By: Claude Opus 4.8 <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.
Problem
scripts/sync-android-docs.jsrewrites bare sibling slugs to.mdso Docusaurus resolves them as pages. ButrewriteSiblingLinksmatched the whole link against the known-slug set, so a link with an anchor —node-metrics#air-quality-metrics(indocs/en/user/telemetry-and-sensors.md) — never matched and kept its bare slug.Docusaurus then resolved it as a sub-path of the current page (
.../telemetry-and-sensors/node-metrics/#air-quality-metrics) and failed the meshtastic.org docs build with a broken link (onBrokenLinks: throw). This breaks the auto-generated sync PR every time.Fix
Split off a trailing
#anchor/?querybefore the slug lookups, then re-append it after inserting.md:Covers all three link forms the rewriter handles (index landing, cross-section
../developer/x, and sibling).Verification
Re-ran the sync against current
maindocs: the link now emits.md#air-quality-metrics, and a sweep finds no remaining slug-with-anchor links missing.md.🤖 Generated with Claude Code