Skip to content

Commit 4c10fb8

Browse files
committed
Reverted previous default assignment of compiler.rootRelativeImageURL.
This broke the case where config.rootRelativeImageURL is set to true --> empty string --> false, which is treated differently by the compiler. Added descriptin in configuration.md
1 parent f95b909 commit 4c10fb8

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

docs/configuration.md

+21
Original file line numberDiff line numberDiff line change
@@ -616,3 +616,24 @@ window.$docsify = {
616616
topMargin: 90, // default: 0
617617
};
618618
```
619+
620+
## rootRelativeImageURL
621+
622+
- Type: `Boolean|String`
623+
- Default: `false`
624+
625+
Configure image URL rendering behavior when inserting markdown images when the image URL is root-relative, i.e. starts with '/'.
626+
627+
By default, Docsify resolves all image paths against the current page's parent path.
628+
629+
E.g. if the current path is `/advanced/guide`, `![](/assets/image.png)` would render as `<img src="advanced/assets/image.png">`.
630+
631+
```js
632+
window.$docsify = {
633+
rootRelativeImageURL = false // default behaviour
634+
635+
rootRelativeImageURL = true // ![](/assets/image.png) renders as <img src="/assets/image.png" />
636+
637+
rootRelativeImageURL = 'my-root-path' // ![](/assets/image.png) renders as <img src="/my-root-path/assets/image.png />
638+
}
639+
```

src/core/render/compiler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class Compiler {
6868
this.linkRel =
6969
this.linkTarget === '_blank' ? config.externalLinkRel || 'noopener' : '';
7070
this.contentBase = router.getBasePath();
71-
this.rootRelativeImageURL = config.rootRelativeImageURL || false;
71+
this.rootRelativeImageURL = config.rootRelativeImageURL;
7272

7373
const renderer = this._initRenderer();
7474
this.heading = renderer.heading;

0 commit comments

Comments
 (0)