Closed shadowspawn closed 6 years ago
I saw links working in yargs
using a technically still relative link starting with a slash, which I had not considered.
I changed docs/foo
to /docs/foo
. Thought it was working but nope, still not working for my project.
Filling in some details of setups.
Working link on npmjs for yargs:
[tons more](/docs/api.md)
Broken link on npmjs for me:
[changes to command syntax](/docs/coming-from-n.md)
There was a bug on npmjs end which has been addressed, hurrah! I'll update my npm community bug when I have seen it working.
I thought this was just a bug and cannot believe this is actually the standard behavior on npm. How can relative links work anywhere else but on npm where I publish the package? Is there any official solution? It's madness!!! ;-)
Short version: relative links to other files from my package README are not being turned into github absolute references, and so do not work on npmjs.org.
What I Did
In my raw README I have relative links like:
What I Expected
I assumed it would Just Work on both GitHub and npm, without thinking about the complications for npm hosting! (The other markdown file is not included in the published npm package.)
What Happened Instead
On npmjs the link does not work. The README page source has the relative link and has not been rewritten, and the page is not found:
On GitHub the README page source has:
Details
When I did some digging into the problem I found that marky-markdown has support for rewriting relative links and images using the github package.repository if that is available (#306). Sounds good! But this does not appear to be happening for me.
I checked that github-url-to-object used by marky-markdown could resolve the repository as specified in my package.json and it could.
I changed my package repository reference to https in case #368 had resurfaced, but it did not make a difference.
I found another person talking about various problems with linked images, and they have a sample package with lots of types of links. None of the relative images render on npmjs:
https://www.npmjs.com/package/@code-therapy/packages-with-readme-relative-images
(I posted a message on the npm community but didn't score any replies in a couple of weeks.)