rehype-image-attr; descriptions for plugins
This commit is contained in:
parent
d51f0d3f03
commit
9dda240ebe
4 changed files with 152 additions and 21 deletions
13
rehype-image-attr.mjs
Normal file
13
rehype-image-attr.mjs
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Adds some HTML attributes to images,
|
||||
// only loading=lazy for now
|
||||
|
||||
import { selectAll } from 'unist-util-select'
|
||||
|
||||
export default function rehypeImageAttr() {
|
||||
return (tree, file) => {
|
||||
const imgs = selectAll('element[tagName=img]', tree)
|
||||
for (let img of imgs) {
|
||||
img.properties.loading = 'lazy'
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue