Skip to content

When relativePath: true, even absolute paths are for icons in sidebar are resolved as relative. #877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task
filipgoc opened this issue Jul 4, 2019 · 5 comments

Comments

@filipgoc
Copy link

filipgoc commented Jul 4, 2019

Bug Report

When relativePath: true, absolute paths are for icons in sidebar are resolved as relative.

Steps to reproduce

Set relativePath: true

└── docs
    ├── _sidebar.md
    ├── guide.md
    └── subfolder
        ├── _sidebar.md
        ├── guide.md

In the both _sidebar files, I have - [![](/assets/home.svg)Home](/ "Home")

What is current behaviour

While the link gets resolved as absolute (👍 ),
for images,
the data-origin is correct (👍 ), but the img scr is relative and thus failing (👎 )

<a href="#/" title="Home"><img src="/subfolder/assets/home.svg" data-origin="/assets/home.svg" alt="">Home</a>

What is the expected behaviour

The img src should be absolute:
"/assets/home.svg"

Other relevant information

  • Bug does still occur when all/other plugins are disabled?

  • Your OS:

  • Node.js version:

  • npm/yarn version:

  • Browser version:

  • Docsify version: 4.9.4

  • Docsify plugins: pagination, themeable

@tiptronic
Copy link

While I understand your intention (and you're right), here's a small note:
But both of the mentioned paths are absolute paths:

  • /subfolder/assets/home.svg
  • /assets/home.svg

they simple start at a different root-directory. A relative path would ideally start with an './' (or even without a slash).

This is an important feature, because otherwise it's cumbersome to link from one .md to the contents of another <sibling/parent/child>.md.

@timaschew
Copy link
Member

Resolving image seems to use a different algorithm that's why images are not working.

@timaschew timaschew added bug confirmed as a bug path-resolving labels Nov 22, 2019
@stale
Copy link

stale bot commented Feb 4, 2020

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.

@jcayzac
Copy link

jcayzac commented Dec 10, 2020

I can reproduce this in any page:

![Secure website image](/_assets/secure-website.png)

is resolved as:

  • {base-path}#/_assets/secure-website.png when i'm e.g. at #/quickstart, but as
  • {base-path}#/ja/_assets/secure-website.png, which doesn't exists and returns 404, when i'm e.g. at #/ja/quickstart.

Given the URL is absolute I don't understand why Docsify feels like it should consider it relative, especially since I don't set relativePath.

@jhildenbiddle
Copy link
Member

Bug acknowledged. Tracking with #1891.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants