Skip to content

fix(docs): preserve #anchor when rewriting sibling links for Docusaurus#5963

Merged
jamesarich merged 1 commit into
mainfrom
fix/sync-docs-anchor-links
Jun 26, 2026
Merged

fix(docs): preserve #anchor when rewriting sibling links for Docusaurus#5963
jamesarich merged 1 commit into
mainfrom
fix/sync-docs-anchor-links

Conversation

@jamesarich

Copy link
Copy Markdown
Collaborator

Problem

scripts/sync-android-docs.js rewrites bare sibling slugs to .md so Docusaurus resolves them as pages. But rewriteSiblingLinks matched the whole link against the known-slug set, so a link with an anchor — node-metrics#air-quality-metrics (in docs/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 / ?query before the slug lookups, then re-append it after inserting .md:

node-metrics#air-quality-metrics → node-metrics.md#air-quality-metrics

Covers all three link forms the rewriter handles (index landing, cross-section ../developer/x, and sibling).

Verification

Re-ran the sync against current main docs: the link now emits .md#air-quality-metrics, and a sweep finds no remaining slug-with-anchor links missing .md.

🤖 Generated with Claude Code

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>
@jamesarich jamesarich merged commit a511fcf into main Jun 26, 2026
11 checks passed
@jamesarich jamesarich deleted the fix/sync-docs-anchor-links branch June 26, 2026 12:30
@github-actions github-actions Bot added the bugfix PR tag label Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant