Skip to content

Commit f087beb

Browse files
committed
Fix image sizes with sizes: auto
1 parent 125b23a commit f087beb

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

generate/plugin/rehype-pictures.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,24 @@ export default function rehypePictures(options) {
9090
/** @type {Set<string>} */
9191
const available = new Set()
9292
// See which images exist.
93-
/** @type {Array<() => Promise<undefined>>} */
93+
/** @type {Array<Promise<undefined>>} */
9494
const tasks = []
9595

9696
for (const d of sources) {
97-
tasks.push(async function () {
98-
const file = new VFile({path: localUrl})
99-
rename(file, d)
100-
101-
try {
102-
await fs.access(file.path, fs.constants.R_OK)
103-
} catch {
104-
return
105-
}
97+
tasks.push(
98+
(async function () {
99+
const file = new VFile({path: localUrl})
100+
rename(file, d)
101+
102+
try {
103+
await fs.access(file.path, fs.constants.R_OK)
104+
} catch {
105+
return
106+
}
106107

107-
available.add(file.path)
108-
})
108+
available.add(file.path)
109+
})()
110+
)
109111
}
110112

111113
await Promise.all(tasks)
@@ -159,6 +161,7 @@ export default function rehypePictures(options) {
159161

160162
node.properties.height = info.height
161163
node.properties.loading = 'lazy'
164+
node.properties.sizes = 'auto'
162165
node.properties.width = info.width
163166

164167
const siblings = parent.children

0 commit comments

Comments
 (0)