Navigation Menu

Skip to content

Commit

Permalink
fix: markdown 中的 img 标签无法调整图片大小
Browse files Browse the repository at this point in the history
  • Loading branch information
Mereithhh committed Sep 28, 2022
1 parent fda963d commit 3e2dbfa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions packages/website/components/ImageBox/index.tsx
Expand Up @@ -9,6 +9,9 @@ export default function (props: {
alt: string | undefined;
lazyLoad: boolean;
className?: string;
width?: any;
height?: any;
style?: any;
}) {
const [error, setError] = useState(false);
if (!error) {
Expand All @@ -22,6 +25,9 @@ export default function (props: {
onError={() => {
setError(true);
}}
width={props.width}
height={props.height}
style={props.style}
loading={props.lazyLoad ? "lazy" : undefined}
/>
</PhotoView>
Expand All @@ -33,6 +39,9 @@ export default function (props: {
className={props.className}
src={errorImg}
alt={props.alt}
width={props.width}
height={props.height}
style={props.style}
loading={props.lazyLoad ? "lazy" : undefined}
/>
);
Expand Down
5 changes: 4 additions & 1 deletion packages/website/components/Markdown/Img.tsx
@@ -1,11 +1,14 @@
import ImageBox from "../ImageBox";

export default function(props: any) {
export default function (props: any) {
const { node } = props;
const { properties } = node || {};
return (
<ImageBox
alt={props.alt}
src={(props.src as string) || ""}
lazyLoad={true}
{...properties}
/>
);
}

0 comments on commit 3e2dbfa

Please sign in to comment.