Fumadocs

可缩放图片

允许在文档中放大图片

banner

Install to your codebase

Easier customisation & control.

使用

🌐 Usage

在你的 MDX 组件中将 img 替换为 ImageZoom

🌐 Replace img with ImageZoom in your MDX components.

mdx-components.tsx
import { ImageZoom } from 'fumadocs-ui/components/image-zoom';
import defaultComponents from 'fumadocs-ui/mdx';
import type { MDXComponents } from 'mdx/types';

export function getMDXComponents(components?: MDXComponents): MDXComponents {
  return {
    ...defaultComponents,
    img: (props) => <ImageZoom {...(props as any)} />,
    ...components,
  };
}

现在所有图片将自动启用图片缩放功能。

🌐 Now image zoom will be automatically enabled on all images.

![Test](/banner.png)

图片优化

🌐 Image Optimization

在 Next.js 中,如果未指定,将为 <Image /> 组件定义默认的 sizes 属性

🌐 On Next.js, a default sizes property will be defined for <Image /> component if not specified.

Last updated on

On this page