Skip to content

Commit f31cce6

Browse files
Searching the className issue in the fog
1 parent cae765c commit f31cce6

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

.changeset/hungry-crews-return.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'astro-m2dx-image': patch
3+
'm2dx-utils': patch
4+
---
5+
6+
Searching the className issue in the fog

packages/astro-m2dx-image/lib/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export { default as Image } from './Image.astro';
33
export { default as Picture } from './Picture.astro';
44
export * from './types';
55

6+
// This cannot be simply reexported, because of some rollup issues when using the package
67
export function parseAspectRatio(aspectRatio?: AspectRatio): number | undefined {
78
if (!aspectRatio) {
89
return undefined;

packages/m2dx-utils/src/embeddedHast.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ export function addHClasses(node: Node, ...classes: string[]) {
4545
existing.split(/\s/).forEach((s) => merged.add(s));
4646
}
4747

48-
classes.filter(isString).forEach((c) => c?.split(/\s+/).forEach((s) => !!s && merged.add(s)));
48+
classes
49+
.filter(isString)
50+
.forEach((c) => c?.split(/\s/).forEach((s) => !!s && s.trim().length > 0 && merged.add(s)));
4951
if (merged.size > 0) {
50-
getHProperties(node).class = [...merged].join(' ');
52+
getHProperties(node)['class'] = [...merged].join(' ');
5153
}
5254
}

0 commit comments

Comments
 (0)