diff --git a/README.md b/README.md
index ed921e3..7b824b7 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,7 @@ marked:
autolink: true
sanitizeUrl: false
headerIds: true
+ lazyload: false
prependRoot: false
external_link:
enable: false
@@ -47,6 +48,7 @@ marked:
- **autolink** - Enable autolink for URLs. E.g. `https://hexo.io` will become `https://hexo.io`.
- **sanitizeUrl** - Remove URLs that start with `javascript:`, `vbscript:` and `data:`.
- **headerIds** - Insert header id, e.g. `
text
`. Useful for inserting anchor link to each paragraph with a heading.
+- **lazyload** - Lazy loading images via `loading="lazy"` attribute.
- **prependRoot** - Prepend root value to (internal) image path.
* Example `_config.yml`:
``` yml
diff --git a/index.js b/index.js
index 698f6a7..4a82c9b 100644
--- a/index.js
+++ b/index.js
@@ -14,6 +14,7 @@ hexo.config.marked = Object.assign({
autolink: true,
sanitizeUrl: false,
headerIds: true,
+ lazyload: false,
// TODO: enable prependRoot by default in v3
prependRoot: false,
external_link: {
diff --git a/lib/renderer.js b/lib/renderer.js
index ed8900f..0ca933d 100644
--- a/lib/renderer.js
+++ b/lib/renderer.js
@@ -93,6 +93,7 @@ class Renderer extends MarkedRenderer {
let out = `';
return out;
diff --git a/test/index.js b/test/index.js
index cd2c655..b81e7a9 100644
--- a/test/index.js
+++ b/test/index.js
@@ -573,6 +573,24 @@ describe('Marked renderer', () => {
].join('\n'));
});
+ it('lazyload image', () => {
+ const body = [
+ '![](/bar/baz.jpg)',
+ '![foo](/aaa/bbb.jpg)'
+ ].join('\n');
+
+ ctx.config.marked.lazyload = true;
+
+ const r = require('../lib/renderer').bind(ctx);
+
+ const result = r({ text: body });
+
+ result.should.eql([
+ '',
+ '
\n'
+ ].join('\n'));
+ });
+
describe('exec filter to extend', () => {
it('should execute filter registered to marked:renderer', () => {
const hexo = new Hexo(__dirname, {silent: true});