blob: f42d9ec524baacb65bef1ca009779ab6ee857057 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
export default function plugin() {
return transformer;
function transformer(tree) {
function traverse(node) {
if (node.type === "image") {
node.data = node.data || {};
node.data.hProperties = node.data.hProperties || {};
node.data.hProperties.id = "test";
node.data.hProperties.width = "300";
node.data.hProperties.widths = [300,600];
node.data.hProperties.sizes = "(min-width: 600px) 600w, 300w";
}
if (node.children) {
node.children.forEach(traverse);
}
}
traverse(tree);
}
}
|