内联图像未从 GatsbyJS 中的 markdown 文件正文加载

2024-02-21

我正在尝试使用 gatsby-remark-images 在我的 markdown 文件中使用内联图像。不幸的是,该图像无法加载到我的本地主机上。我不知道这是否只是语法错误,或者我错过了一些重大的东西。

这是config https://github.com/wbonneville/gatsby_blog/blob/master/gatsby-config.js:(我怀疑我在某个地方做错了什么,就在这里。)

module.exports = {
  siteMetadata: {
    title: ``,
    description: `A blog where code is written about`,
    author: `@wesley`,
  },

  plugins: [
    `gatsby-plugin-sass`,
    `gatsby-plugin-styled-components`,
    `gatsby-plugin-react-helmet`,
    `gatsby-plugin-catch-links`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `${__dirname}/src/images`,
      },
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `${__dirname}/src/pages`,
      },
    },
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-remark-images`,
            options: {
              // It's important to specify the maxWidth (in pixels) of
              // the content container as this plugin uses this as the
              // base for generating different widths of each image.
              maxWidth: 1200,
            },
          },
        ],
      },
    },

    `gatsby-transformer-remark`,
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `gatsby-starter-default`,
        short_name: `starter`,
        start_url: `/`,
        background_color: `#663399`,
        theme_color: `#663399`,
        display: `minimal-ui`,
        icon: `src/images/mt.png`, // This path is relative to the root of the site.
      },
    },
    // this (optional) plugin enables Progressive Web App + Offline functionality
    // To learn more, visit: https://gatsby.dev/offline
    // `gatsby-plugin-offline`,
  ],
};

我一遍又一遍地仔细研究有关盖茨比的糟糕文档。我很困惑。有人知道发生了什么事吗?我能够让特色图像发挥作用,但这不是我想要的。

package.json: here's the json package

Path in markdown file is right (I believe): path is right (i believe)

Screenshot of what I'm getting: but this is what i'm getting


我想如果你删除以下内容line https://github.com/wbonneville/gatsby_blog/blob/master/gatsby-config.js#L44从你的 Gatsby 配置来看,它会起作用。

Gatsby 配置使用该行而不是之前定义的配置。这就是为什么gatsby-remark-images未使用插件。

你在 markdown 文件中的相对路径是正确的../../images/train.png.

从您的配置中提取行:

module.exports = {
 plugins: [
    // ... other plugins
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-remark-images`,
            options: {
              // It's important to specify the maxWidth (in pixels) of
              // the content container as this plugin uses this as the
              // base for generating different widths of each image.
              maxWidth: 1200,
            },
          },
        ],
      },
    },

    // `gatsby-transformer-remark`, // remove this as it will override previous configuration 
   ]
};

Screenshot of the loaded image: train image

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

内联图像未从 GatsbyJS 中的 markdown 文件正文加载 的相关文章

随机推荐

  • Windows 上的 Python str 与 unicode,Python 2.7,为什么 'á' 变成 '\xa0'

    背景 我使用的是 Windows 机器 我知道不再支持 Python 2 但我仍在学习 Python 2 7 16 我还有Python 3 7 1 我知道Python 3 unicode被重命名为str https stackoverflo
  • EntityManagerFactory 已关闭,Hibernate

    我最近创建了一个 Web 服务 它使用 Java 中的静态方法从数据库中获取项目列表 Web 服务运行良好 并将 JSON 返回给调用者 然而 它只能工作一次 如果您尝试刷新或提出新请求 我会收到一个EntityManagerFactory
  • J:牛顿法的隐性副词

    我发现在 addons math misc brent ijs 布伦特方法作为副词的实现 我也想构建牛顿法作为副词 但这比构建默认动词要困难得多 这是牛顿迭代的显式版本 newton i 1 u u d 1 有了这样的用法 2 o newt
  • 在哪里可以找到 javascript 本机函数源代码? [复制]

    这个问题在这里已经有答案了 哪里可以找到原生js函数的源码 比如我想看一下eval 功能 Chrome 和 Firefox 都是开源的 您可以在这些产品的源代码中查看 javascript 引擎任何部分的实现 其他浏览器有自己的实现 例如
  • Android 上的 Cordova 全屏黑条

    我的 android cordova 应用程序在屏幕顶部和底部出现黑色水平条 我尝试将全屏插件和标签添加到 config xml 但它不会消失 https i stack imgur com esFEL png https i stack
  • 从 mongodb 结果 java 中删除 _id

    我的代码是 DBCollection collection db getCollection volume DBCursor cursor collection find DBObject resultElement cursor next
  • Oracle 数据库查询在第二次运行时抛出错误

    我有一个 VBA 代码 我在其中调用 oracle 使用 ODBC 检索数据两次 第一次数据检索没问题 但第二次却说 RunTime Error 2147467259 80004005 Unspecified error 我的代码如下 注意
  • 如何禁用 NSDocument 的窗口标题弹出窗口

    我有一个基于 NSDocument 的应用程序 启用了自动保存 I d like to prevent this popup from showing 我尝试从 NSWindow 的 title representedFilename 和
  • 如何在访问 laravel 环境和类时在命令行上运行 php 脚本

    我在 Web 服务器上有一个 laravel 3 环境 但我想在命令行上运行 php 脚本 我想访问 laravel 环境中的任何 php 脚本 例如控制器 模型或视图文件 访问的相同类和方法 我怎样才能做到这一点 我强烈建议您将 PHP
  • Python - SQLite JSON1 加载扩展

    我想在 Python 中使用 SQLite 的 json1 扩展 根据官方文档 http sqlite org json1 html 它应该是一个可加载的扩展 我从以下位置获取了 json1 c 文件source http sqlite o
  • 在Python中解压文件

    我通读了zipfile文档 https docs python org 3 library zipfile html 但不明白如何unzip一个文件 仅介绍如何压缩文件 如何将 zip 文件的所有内容解压缩到同一目录中 import zip
  • Haskell:在更新函数中引用先前更新的列表元素

    假设我有以下定义 data Book Book id Int title String type Shelf Book 假设我有一个假设的功能 upd用于更新 updShelf Shelf gt Shelf updShelf all boo
  • OSGI环境中单例的迁移解决方案

    我正在 Java EE 环境中工作 其中每个应用程序都位于其自己的 war 文件中 在每个应用程序 war 文件的 WEB INF lib 中 有一个由所有应用程序共享的公共 jar 这个公共 jar 包含几个可以从代码中的许多点访问的单例
  • 从 HashMap 获取值时为什么需要双 & 符号?

    我在 Rust 中的引用方面遇到了一些麻烦 我有以下无法编译的代码 use std collections HashMap fn main let mut map HashMap new map insert 0 0 map insert
  • 按发布降序显示帖子

    我正在尝试测试 Firebase 以允许用户使用以下方式发表评论push 我想用以下内容显示我检索到的数据 fbl child sell limit 20 on value function fbdata handle data displ
  • 当向 RecyclerView ListAdapter 提交新列表时,差异检查始终为 areContentsTheSame() 返回 true

    我正在使用 MVVM 架构来构建一个简单的订购应用程序 我在 ProductsFragment 中使用 RecyclerView 来列出所有可以订购的产品 我还在我的 ViewModel 中使用 LiveData 并在我的 Fragment
  • 满足我需求的强制门户

    我正在为我的组织寻找强制门户 我看到很多这样的应用程序将允许用户在 a 输入凭据或 b 付款后通过 我正在寻找的东西有点不同 让我介绍一些有关我的系统的基础知识 我正在使用活动目录和内部 DNS 运行基于 Windows 的网络 我有一个内
  • jquery Flexslider 手动控件不起作用

    我正在尝试为 flexslider 插件实现手动控制 这是我的代码 div class container div class columns row div class flexslider ul class slides li styl
  • 从 Flask-sqlalchemy 中的连接查询读取

    成功连接两个数据库表后 我尝试通过寻址第一个表来读取第二个表中的数据 我正在致辞opinion topic name来自我的 jinja2 模板 但没有返回任何内容 如何从连接的查询中访问 Topic topic name 值 view m
  • 内联图像未从 GatsbyJS 中的 markdown 文件正文加载

    我正在尝试使用 gatsby remark images 在我的 markdown 文件中使用内联图像 不幸的是 该图像无法加载到我的本地主机上 我不知道这是否只是语法错误 或者我错过了一些重大的东西 这是config https gith