Skip to content

fix: links#147

Open
dcrawbuck wants to merge 1 commit intomainfrom
dcrawbuck/add-link-checks
Open

fix: links#147
dcrawbuck wants to merge 1 commit intomainfrom
dcrawbuck/add-link-checks

Conversation

@dcrawbuck
Copy link
Collaborator

@dcrawbuck dcrawbuck commented Mar 17, 2026

This updates docs URL normalization so legacy aliases, stale hashes, and relative MDX links canonicalize to the right /docs destinations, with a runtime fallback for old hash links. It adds two validation layers: a next-validate-link source check in bun test and a built-site HTML crawler in bun run build that fails on missing internal paths or fragment IDs. The branch also fixes the Android broken fragment, refreshes the iOS local resources and variable reference docs, updates AGENTS.md for the TanStack Start/Vite stack, and disables the Cloudflare inspector that was causing Miniflare EPIPE failures during prerender.

Resolves SW-4876.


Note

Medium Risk
Moderate risk because it changes URL normalization/redirect behavior and makes bun run build fail on broken internal links, which could impact navigation and CI if edge cases are missed.

Overview
Improves internal docs link stability by expanding normalizeDocsInternalHref to canonicalize legacy paths/hashes, resolve relative MDX links (with file context), and apply redirect/alias maps, with updates to remark-link-paths and a runtime LegacyDocsLinkRedirects fallback for old hash-only links.

Adds automated link validation: next-validate-link checks for source MD/MDX (check:links:source, plus a new test) and a post-build HTML crawl (check:links) that fails the build on missing internal paths or fragment IDs. Also updates docs content (iOS local resources page, variable reference table formatting, Android fragment fix), updates AGENTS.md for the Vite/Start stack, and disables the Cloudflare inspector port to avoid prerender EPIPE issues.

Written by Cursor Bugbot for commit 8ea2545. This will update automatically on new commits. Configure here.

@linear
Copy link

linear bot commented Mar 17, 2026

SW-4876 [docs] fix links

@cloudflare-workers-and-pages
Copy link

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
superwall-docs-staging 8ea2545 Commit Preview URL

Branch Preview URL
Mar 17 2026, 09:08 PM

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ea2545885

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +62 to +64
if (baseSegments.length > 1) {
baseSegments.pop();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve section path when resolving links from index pages

resolveRelativeDocsPath always removes the last segment of currentDocPath, but buildDocsPathFromSourceFile already strips /index from index files. For an index page like /content/docs/ios/index.mdx, a relative link such as ./quickstart/install is rewritten to /docs/quickstart/install instead of /docs/ios/quickstart/install, so relative links authored in section landing pages are canonicalized to the wrong destination.

Useful? React with 👍 / 👎.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

function mergeResolvedUrl(input: string, query: string, hash: string): string {
const { pathPart, query: resolvedQuery, hash: resolvedHash } = splitUrlParts(input);
return `${pathPart}${resolvedQuery || query}${resolvedHash || hash}`;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale hash appended to external redirect URLs

Low Severity

mergeResolvedUrl falls back to the original hash argument when the input string has no hash. Since canonicalizeDocsPathname only ever receives and returns pure pathnames, its return value never contains a hash, making resolvedHash always "". When canonicalizeDocsPathname resolves a path to an external URL (e.g. /docs/troubleshootinghttps://support.superwall.com/...), any non-aliased hash from the original input (e.g. #some-section) gets appended to that external URL, producing an incorrect href like https://support.superwall.com/...#some-section.

Fix in Cursor Fix in Web

}, [pathname, hash]);

return null;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Runtime hash redirect never fires on canonical paths

Low Severity

LegacyDocsLinkRedirects calls resolveDocsLinkAlias(fullPath, hash) where fullPath is built from TanStack Router's already-basepath-stripped pathname. For a full-page navigation to an old URL like /docs/campaigns-audience#matching-to-entitlements, the server middleware redirects the path to /docs/dashboard/dashboard-campaigns/campaigns-audience, and the browser appends the original fragment. The component then sees the canonical path plus the stale hash, but DOCS_LINK_ALIASES only has the old pre-redirect path as its key — so no alias matches and the stale hash is never corrected. The intent of the PR ("runtime fallback for old hash links") is thus unmet for any alias where the page path itself also changed.

Additional Locations (1)
Fix in Cursor Fix in Web

@dcrawbuck dcrawbuck changed the title Systematize docs links after Start migration fix: links Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant