Skip to content

Commit abfcb72

Browse files
Fixed error in last release
1 parent e5bf20d commit abfcb72

File tree

5 files changed

+48
-27
lines changed

5 files changed

+48
-27
lines changed

.changeset/funny-walls-drive.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro-m2dx-image': patch
3+
---
4+
5+
Fixed error in last release

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
"@changesets/changelog-github": "^0.4.7",
3232
"@changesets/cli": "^2.25.2",
3333
"eslint-config-base": "workspace:*",
34-
"pnpm": "^7.16.1",
35-
"prettier": "^2.7.1",
34+
"pnpm": "^7.17.0",
35+
"prettier": "^2.8.0",
3636
"prettier-plugin-astro": "^0.7.0",
3737
"rimraf": "^3.0.2",
3838
"turbo": "^1.6.3"

packages/astro-m2dx-image/lib/Image.astro

+8-16
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
11
---
22
import { Image } from '@astrojs/image/components';
3-
import type { ImageMetadata, ImageProps } from './types';
4-
import {
5-
getAspectRatio,
6-
getFallbackAspectRatio,
7-
getFallbackWidth,
8-
getHeight,
9-
getSrc,
10-
getWidth,
11-
parseAspectRatio,
12-
resolveSrc,
13-
} from './utils';
3+
import { parseAspectRatio } from '.';
4+
import { getAspectRatio, getFallbackAspectRatio, getFallbackWidth, resolveSrc } from './internal';
5+
import type { CallbackProps, ImageProps } from './types';
146
157
export interface Props extends ImageProps {}
168
17-
const props = Astro.props as Props;
18-
await resolveSrc(props);
9+
const props = Astro.props as CallbackProps;
10+
props.src = await resolveSrc(props.src);
1911
20-
props.width ??= getWidth(props);
21-
props.height ??= getHeight(props);
12+
props.width ??= props.src.width;
13+
props.height ??= props.src.height;
2214
if (!props.width || !props.height) {
23-
const src = getSrc(props.src as string | ImageMetadata);
15+
const src = props.src.src;
2416
const alt = props.alt;
2517
const aspectRatio =
2618
parseAspectRatio(getAspectRatio(props)) ?? //
+13-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
export { parseAspectRatio } from '@astrojs/image/dist/loaders';
1+
import type { AspectRatio } from './types';
22
export { default as Image } from './Image.astro';
33
export { default as Picture } from './Picture.astro';
44
export * from './types';
5+
6+
export function parseAspectRatio(aspectRatio?: AspectRatio): number | undefined {
7+
if (!aspectRatio) {
8+
return undefined;
9+
}
10+
if (typeof aspectRatio === 'number') {
11+
return aspectRatio;
12+
} else {
13+
const [width, height] = aspectRatio.split(':');
14+
return parseInt(width) / parseInt(height);
15+
}
16+
}

pnpm-lock.yaml

+20-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)