Skip to content

Commit

Permalink
Reverted previous default assignment of compiler.rootRelativeImageURL.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
weijunyu committed Aug 24, 2020
1 parent f95b909 commit 4c10fb8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -616,3 +616,24 @@ window.$docsify = {
topMargin: 90, // default: 0
};
```

## rootRelativeImageURL

- Type: `Boolean|String`
- Default: `false`

Configure image URL rendering behavior when inserting markdown images when the image URL is root-relative, i.e. starts with '/'.

By default, Docsify resolves all image paths against the current page's parent path.

E.g. if the current path is `/advanced/guide`, `![](/assets/image.png)` would render as `<img src="advanced/assets/image.png">`.

```js
window.$docsify = {
rootRelativeImageURL = false // default behaviour

rootRelativeImageURL = true // ![](/assets/image.png) renders as <img src="/assets/image.png" />

rootRelativeImageURL = 'my-root-path' // ![](/assets/image.png) renders as <img src="/my-root-path/assets/image.png />
}
```
2 changes: 1 addition & 1 deletion src/core/render/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class Compiler {
this.linkRel =
this.linkTarget === '_blank' ? config.externalLinkRel || 'noopener' : '';
this.contentBase = router.getBasePath();
this.rootRelativeImageURL = config.rootRelativeImageURL || false;
this.rootRelativeImageURL = config.rootRelativeImageURL;

const renderer = this._initRenderer();
this.heading = renderer.heading;
Expand Down

0 comments on commit 4c10fb8

Please sign in to comment.