Skip to content

Conversation

@JarvisInvestInsight
Copy link
Contributor

@JarvisInvestInsight JarvisInvestInsight commented Feb 2, 2026

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.

Fixes npmx-dev#617
@vercel
Copy link

vercel bot commented Feb 2, 2026

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

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Feb 2, 2026 7:57am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Feb 2, 2026 7:57am
npmx-lunaria Ignored Ignored Feb 2, 2026 7:57am

Request Review

@danielroe danielroe enabled auto-merge February 2, 2026 08:23
@danielroe danielroe added this pull request to the merge queue Feb 2, 2026
Merged via the queue into npmx-dev:main with commit b914c04 Feb 2, 2026
13 checks passed
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.

Change origin of md relative links

2 participants