我正在关注Andrew Mead在Gatsby Bootcamp上的youtube教程,直到3:10:00分钟,一切都很顺利,但一旦我安装了gatsby-remark-relative-images和gatsby-remark-images插件,并将它们添加到gatsby-config.js文件中以显示图像,当我运行npm run develop时,我得到一个错误,如下图所示。

下面是我的gatsby-config.js文件。
/**
* Configure your Gatsby site with this file.
*
* See: https://www.gatsbyjs.org/docs/gatsby-config/
*/
module.exports = {
/* Your site config here */
siteMetadata:{
title:'Gatsby Bootcamp',
author:'Author'
},
plugins: [
'gatsby-plugin-sass',
{
resolve:'gatsby-source-filesystem',
options:{
name: 'src',
path: `${__dirname}/src/`
}
},
'gatsby-plugin-sharp',
{
reslove: 'gatsby-transformer-remark',
options:{
plugins:[
'gatsby-remark-relative-images',
{
resolve:'gatsby-remark-images',
options:{
maxWidth:750,
linkImagesToOriginal: false
}
}
]
}
}
]
}
请帮帮我!提前谢谢你。
发布于 2020-08-13 23:01:23
作为documentation explains,您必须在gatsby-node.js中添加以下代码片段
const { fmImagesToRelative } = require('gatsby-remark-relative-images');
exports.onCreateNode = ({ node }) => {
fmImagesToRelative(node);
};这将获取gatsby-source插件返回的每个节点,如果找到匹配的文件,则会将markdown前端数据中的任何绝对路径转换为相对路径。
https://stackoverflow.com/questions/63397280
复制相似问题