Add: image processing

This commit is contained in:
2022-04-06 11:42:49 +08:00
parent ffda9a99c5
commit eab546a7b6
2 changed files with 25 additions and 1 deletions

View File

@@ -9,7 +9,6 @@ const components = {
h4: (props) => <Typography variant="h4" {...props} />, h4: (props) => <Typography variant="h4" {...props} />,
h5: (props) => <Typography variant="h5" {...props} />, h5: (props) => <Typography variant="h5" {...props} />,
h6: (props) => <Typography variant="h6" {...props} />, h6: (props) => <Typography variant="h6" {...props} />,
img: (props) => <Image alt={props.alt} layout="responsive" {...props} />,
code: (props) => ( code: (props) => (
<code <code
style={{ style={{

25
pages/posts/images.mdx Normal file
View File

@@ -0,0 +1,25 @@
export const meta = {
"title": "图片处理",
"date": "2022-03-05",
"description": "使用 Next.js 的图片组件对图像进行预处理。"
};
import PostLayout from '../../components/PostLayout';
import guguguImage from '../../public/images/gugugu.webp';
import Image from 'next/image';
图片示例
<Image src={guguguImage} layout="responsive" />
此处使用了 Next.js 的 `Image` 组件。优点包括:
- 在构建时图片预先被转换成多种分辨率,根据用户设备大小返回相应的分辨率图片。
- 提升加载速度。
- 在未加载完整图片是显示一个模糊的预览图。
- 防止 *加载时布局移动*
export default ({children}) => <PostLayout meta={meta}>{children}</PostLayout>