Docsify: Embedded files doesn't resolve relative links

Created on 8 Jun 2019  路  11Comments  路  Source: docsifyjs/docsify




Bug Report

Docsify doesn't resolve relative links in embedded markdown files correctly. Whenever MD file contains any relative link instead of file content user just gets Not found 404 error.

Steps to reproduce

README.md

[Task](./task/README.md ':include')

task/README.md

# Crossword:

On the last page you found a weird crossword puzzle. Perhaps it reveals a flag for you.

[crosswords.png](./crosswords.png ':ignore')

task/crosswords.png

What is current behaviour

Link to crosswords.png points to /crosswords.png

What is the expected behaviour

Link to crosswords.png should point to /task/crosswords.png

Other relevant information

  • [x] Bug does still occur when all/other plugins are disabled?
  • Your OS: Ubuntu 16.04
  • Node.js version: v10.15.3
  • npm/yarn version: 6.4.1
  • Browser version: 74.0.3729.169
  • Docsify version: 4.9.4
  • Docsify plugins: N/A

bug path-resolving

All 11 comments

I second the problem. This makes embeds useless unless everything is plain text with no media.

Is this a bug or a limitation?

Is there a way to handle this with aliases in the index file? (I tried, but unsuccessfully.)

This is a duplicate of the very old https://github.com/docsifyjs/docsify/issues/695, but this issue contains more info and a formatted example.

This really messes up my workflow. If anyone has any ideas for a workaround (not even thinking of a fix, just a hack), please. Any suggestions welcome!

Ok I have a workaround. Phew. It's NOT a fix, but it makes it workable; with a bit of manual work.

Add relative symlinks to all the relevant directories and files.

In the most simple case, let's say I have assets folder where all the images are stored.

I can add a symlink to this folder with the same name, and the relative links resolve correctly (through the symlink).

I have tested it and it works.

Feel free to ping me if you're trying the same thing and have issues.

Tip: I also discovered I needed to add an empty
<span></span> at the end of every markdown file that has an :include, otherwise my footer does not work properly (my footer is created as a plugin in the index.html...)

As in

Some paragraph. 

[filename](include.md ':include')

<span></span>

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Hello, we have this issue as well in our website based on docsify, please keep it open until #867 is either merged or closed.

I believe this issue is still happening, we are currently using docsify 4.11.3, I need to create a dedicated example.

create a separate issue if it still exists with sandbox example.

Thanks

That's the plan 馃槈

I actually found out that in order to have the behaviour I wanted, I had to set option relativePath to true.

https://docsify.js.org/#/configuration?id=relativepath

There is a side effect though, the sidebar links become relative to the current path.
This can be solved (or worked around) by making the sidebar links absolute.

I could not find whether this is by design or if it is a bug, should I report it as an issue?
I have a repository demonstrating it: https://dellagustin-sap.github.io/docsify-relative-path-bug-report/#/

I found out that the behavior I reported in the previous comment related to relative paths and the sidebar was already reported here: https://github.com/docsifyjs/docsify/issues/925

Was this page helpful?
0 / 5 - 0 ratings