盖茨比的静态图像未在故事书中呈现

Teo*_*oTN 6 javascript gatsby storybook

我正在尝试用 Gatsby 的组件为我的组件编写一本故事书StaticImage,但这最终什么也没有呈现,并且在控制台中伪装成警告的错误:

Please ensure that "gatsby-plugin-image" is included in the plugins array in gatsby-config.js, and that your version of gatsby is at least 2.24.78
(anonymous) @ static-image.server.tsx:52
Run Code Online (Sandbox Code Playgroud)

我想知道是否有办法StaticImage在 Gatsby 之外使用渲染组件?

组件很简单:

import React from 'react';
import { StaticImage } from 'gatsby-plugin-image';

export const Card = ({ title }) => {
  return (
    <div>
      <div>{title}</div>
      <StaticImage src="../../assets/images/background.png" alt="" width={300} height={100}/>
    </div>
  );
};
Run Code Online (Sandbox Code Playgroud)

我正在使用 Gatsby v3 和 Storybook v6.3

小智 2

根据Gatsby 文档,目前尚不支持。

注意:目前不支持为使用 gatsby-plugin-image 中的 StaticImage 的组件编写故事。欢迎为实现这一目标做出贡献。