Skip to content

fix: resolve relative markdown links to repository blob URLs - #716

Merged
danielroe merged 3 commits into
npmx-dev:mainfrom
JarvisInvestInsight:fix/md-relative-links-v2
Feb 2, 2026
Merged

fix: resolve relative markdown links to repository blob URLs#716
danielroe merged 3 commits into
npmx-dev:mainfrom
JarvisInvestInsight:fix/md-relative-links-v2

Conversation

@JarvisInvestInsight

@JarvisInvestInsightJarvisInvestInsight commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Resolves relative markdown (.md) links in READMEs to the source repository's blob URLs instead of raw URLs or jsdelivr CDN.

Problem

As reported in #617, relative links to other markdown files in READMEs were resolving incorrectly:

  • Links pointed to \cdn.jsdelivr.net/npm/...\ which returns 404 for files not in the npm tarball
  • Even when files existed, jsdelivr serves raw markdown text (not rendered)
  • Users expected to navigate to the rendered documentation on GitHub/GitLab/etc.

Example from issue:
\
Link in README: ./docs/03-customization/README.md
Was resolving to: https://cdn.jsdelivr.net/npm/robindoc/docs/03-customization/README.md (404)
Should resolve to: https://github.com/robindoc/robindoc/blob/HEAD/docs/03-customization/README.md
\\

Solution

  1. Added \getBlobBaseUrl\ to all git providers - Returns the base URL for viewing rendered files (e.g., /blob/\ for GitHub, /src/\ for Gitea/Codeberg, /-/blob/\ for GitLab)

  2. Updated \RepositoryInfo\ interface - Now includes \�lobBaseUrl\ alongside
    awBaseUrl\

  3. Modified
    esolveUrl\ logic for .md\ files:

    • If repo info available → use \�lobBaseUrl\ (renders on provider)
    • If no repo info → leave URL unchanged (matches npm behavior)
    • Non-.md\ files → unchanged behavior (raw URLs or jsdelivr)

Supported Providers

GitHub, GitLab (including self-hosted), Bitbucket, Codeberg, Gitee, Sourcehut, Tangled, Radicle, Forgejo, Gitea

Fixes#617


Found this helpful? ☕ Buy me a coffee

Previously, relative .md links in READMEs would resolve to jsdelivr CDN
(which returns raw markdown text) or raw GitHub URLs. This caused 404s
for files not in the npm tarball and poor UX for files that exist.
Changes:
- Add getBlobBaseUrl to all git provider configs
- Add blobBaseUrl to RepositoryInfo interface
- Update resolveUrl to use blob URLs for .md files (so they render)
- Leave .md links unchanged if no repo info (matches npm behavior)
This allows users to navigate to other documentation files and see them
rendered properly on the source repository.
Fixesnpmx-dev#617
@vercel

vercelBot commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
npmx.devReadyReadyPreview, CommentFeb 2, 2026 7:57am
2 Skipped Deployments
ProjectDeploymentActionsUpdated (UTC)
docs.npmx.devIgnoredIgnoredPreviewFeb 2, 2026 7:57am
npmx-lunariaIgnoredIgnoredFeb 2, 2026 7:57am

Request Review

@danielroe
danielroe added this pull request to the merge queueFeb 2, 2026
Merged via the queue into npmx-dev:main with commit b914c04Feb 2, 2026
13 checks passed
taskylizard pushed a commit to taskylizard/npmx.dev that referenced this pull request Feb 7, 2026
Sign up for freeto 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.

Change origin of md relative links

2 participants

@JarvisInvestInsight@danielroe