docsifyjs / docsifyjs/docsify

Docsify does not preserve alias when importing an image

未关闭
#1,870 3 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看
enhancement
主要语言
JavaScript
星标
31.5k
派生
5.8k
平均合并
9 天 8 小时
30 天内合并 PR
2

描述

## Bug Report

#### Steps to reproduce

This page https://github.com/hamishwillee/mavlink-devguide/blob/demo_for_but/en/guide/serialization.md displays four images.
- The first two display an image in an /assets/ folder using absolute and relative paths.
- The second two display the same image in the same folder.

```
1.
![MAVLink v2 packet](../../assets/packets/packet_mavlink_v2.jpg)

2.
![MAVLink v2 packet](/assets/packets/packet_mavlink_v2.jpg)

3.
![MAVLink v2 packet](packet_mavlink_v2.jpg)

4.

```
If I display this page using an alias none of the images are displayed;
```
'/en/(.*)':
'https://raw.githubusercontent.com/hamishwillee/mavlink-devguide/docsify_test/en/$1'
```

YOu can see why here - the assets folder is not found - either it can't find the assets folder, or it is looking in the root, or it is looking in the right folder locally, and not on the aliased site.

![image](https://user-images.githubusercontent.com/5368500/186576955-cdab6202-a304-4938-8a42-465f01b696b3.png)

I think it should search the relative path of the alias to construct the URL.

#### What is current behaviour

If you load a markdown file using an alias images listed in that file cannot be imported.

#### What is the expected behaviour

If you import a file via an alias its images should be displayed

#### Other relevant information

I think this is the same thing reported in https://github.com/docsifyjs/docsify/issues/1436#issuecomment-737107674

The had a horrible hack to hard code what site they are on into the URL. I'd be OK with that if you could get the information for your current context dynamically maybe, but I'd still hope this bug would be fixed.

- [ x] Bug does still occur when all/other plugins are disabled?

- Your OS: Windows 11
- Node.js version: v16.15.0
- npm/yarn version: yarn 1.22.5
- Browser version: Latest Firefox and Chrome
- Docsify version: 4.x
- Docsify plugins: None

#### Please create a reproducible sandbox

[[![Edit 307qqv236](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/307qqv236)](https://codesandbox.io/s/late-dawn-tvrd7w?file=/README.md)

- click the link to display a test page that loads images

#### Mention the docsify version in which this bug was not present (if any)

All

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。