Skip to content

Commit 6696d3d

Browse files
committed
feat: lazy loading and sync decoding to images in articles
1 parent c8ef628 commit 6696d3d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lib/markdown.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ export async function processMarkdown(content: string): Promise<string> {
8383
title || ""
8484
}" target="_blank" rel="noopener noreferrer">${text}</a>`;
8585
},
86+
87+
image({ href, title, text }) {
88+
return `<img src="${href}" alt="${text}" title="${
89+
title || ""
90+
}" loading="lazy" decoding="async" />`;
91+
},
8692
},
8793
});
8894

@@ -104,7 +110,7 @@ export async function processMarkdown(content: string): Promise<string> {
104110
]),
105111
allowedAttributes: {
106112
a: ["href", "name", "target", "rel", "title"],
107-
img: ["src", "alt", "title", "width", "height", "loading"],
113+
img: ["src", "alt", "title", "width", "height", "loading", "decoding"],
108114
iframe: [
109115
"allow",
110116
"allowfullscreen",

0 commit comments

Comments
 (0)