Skip to content

Commit f0f3f15

Browse files
authored
fix: 限于vercel问题暂时关闭nextjsImage的优化
1 parent c057062 commit f0f3f15

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

mdx-components.tsx

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Image from "next/image";
1+
// import Image from "next/image";
22
import type { ImageProps } from "next/image";
33
import defaultMdxComponents from "fumadocs-ui/mdx";
44
import type { MDXComponents } from "mdx/types";
@@ -11,31 +11,40 @@ type MdxImageProps = ComponentPropsWithoutRef<"img"> & {
1111
};
1212

1313
function MdxImage({ src, alt = "", width, height, ...rest }: MdxImageProps) {
14-
if (!src) {
15-
return (
16-
<img
17-
src={src as string}
18-
alt={alt}
19-
width={width}
20-
height={height}
21-
{...rest}
22-
/>
23-
);
24-
}
25-
const numericWidth = typeof width === "string" ? Number(width) : width;
26-
const numericHeight = typeof height === "string" ? Number(height) : height;
14+
// if (!src) {
15+
// return (
16+
// <img
17+
// src={src as string}
18+
// alt={alt}
19+
// width={width}
20+
// height={height}
21+
// {...rest}
22+
// />
23+
// );
24+
// }
25+
// const numericWidth = typeof width === "string" ? Number(width) : width;
26+
// const numericHeight = typeof height === "string" ? Number(height) : height;
2727

28-
if (!Number.isFinite(numericWidth) || !Number.isFinite(numericHeight)) {
29-
// fallback: 当 width/height 不是可解析数值时,直接使用原生 <img>
30-
return <img src={src ?? ""} alt={alt ?? ""} {...rest} />;
31-
}
28+
// if (!Number.isFinite(numericWidth) || !Number.isFinite(numericHeight)) {
29+
// // fallback: 当 width/height 不是可解析数值时,直接使用原生 <img>
30+
// return <img src={src ?? ""} alt={alt ?? ""} {...rest} />;
31+
// }
3232

33+
// return (
34+
// <Image
35+
// src={src ?? ""}
36+
// alt={alt ?? ""}
37+
// width={numericWidth}
38+
// height={numericHeight}
39+
// {...rest}
40+
// />
41+
// );
3342
return (
34-
<Image
35-
src={src ?? ""}
36-
alt={alt ?? ""}
37-
width={numericWidth}
38-
height={numericHeight}
43+
<img
44+
src={src as string}
45+
alt={alt}
46+
width={width}
47+
height={height}
3948
{...rest}
4049
/>
4150
);

0 commit comments

Comments
 (0)