【问题标题】:gatsby remark images does not display imagegatsby remark 图片不显示图片
【发布时间】:2020-08-15 04:51:21
【问题描述】:

我在其他地方看到过这个并尝试了很多东西,但无法让它为我工作。 .md 身体照片不会通过 gatsby-remark-images 显示。我也已将所有内容更新到最新版本。

更新现在显示完整的配置文件

配置:

const path = require(`path`)

module.exports = {
  siteMetadata: {
    title: `xxx`,
    description: `xxx`,
    author: `xxx`,
  },
  plugins: [
    {
      resolve: `gatsby-remark-images`,
            options: {
              maxWidth: 1500,
              withWebp: true,
              showCaptions: true,
              quality: 100,

            },
    },
    `gatsby-transformer-sharp`,
    `gatsby-transformer-remark`,

    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/images`,
      },
    },

    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `markdown-pages`,
        path: `${__dirname}/src/markdown-pages`,
      },
    },


    `gatsby-plugin-sharp`,
    `gatsby-plugin-react-helmet`,
    `gatsby-plugin-styled-components`,


    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `gatsby-starter-default`,
        short_name: `starter`,
        start_url: `/`,
        background_color: `white`,
        theme_color: `white`,
        display: `minimal-ui`,
        icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
      },
    },
  ],
}

md 内:

![fail](../images/demo/fail.jpeg)

【问题讨论】:

  • 您能向我们展示您的完整 gatsby-config 文件吗?
  • 刚刚更新,谢谢

标签: reactjs gatsby gatsby-image


【解决方案1】:

为了在markdown中使用默认的图片语法,你可以在gatsby-transformer-remarklike的选项中指定gatsby-images-remark插件

{
  resolve: `gatsby-transformer-remark`,
  options: {
    plugins: [
      {
        resolve: `gatsby-remark-images`,
        options: {
          maxWidth: 1500,
          withWebp: true,
          showCaptions: true,
          quality: 100,
        },
      },
    ],
  },
},

查看gatsby documentation 了解更多详情。

【讨论】:

  • 好的,我就是这样设置的。虽然仍然得到相同的结果:(
  • 你清理缓存并重新构建了吗?
  • 是的。我清理并尝试开发和构建。它显示标题和图像图标,但没有图像
  • 图片宽度是否大于1500px?如果是这样,请设置更大的 maxWidth
  • 它现在正在工作。没有意识到照片必须与 .md 文件位于同一文件夹中。我在别处引用了它。
猜你喜欢
  • 2014-10-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-15
  • 2013-12-21
相关资源
最近更新 更多