Wes*_*lle 3 javascript markdown reactjs graphql gatsby
我正在尝试使用 gatsby-remark-images 在我的降价文件中使用内联图像。不幸的是,图像不会加载到我的本地主机上。我不知道这是否只是错误的语法,或者我遗漏了一些严重的东西。
这是配置:(我怀疑我在某处做错了什么,它在这里。)
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`,
],
};
Run Code Online (Sandbox Code Playgroud)
我一遍又一遍地研究了关于 Gatsby 的糟糕文档。我很困惑。任何人都知道发生了什么?我能够让特色图片发挥作用,但这不是我想要的。
包.json:

降价文件中的路径是正确的(我相信):

我得到的截图:

我认为如果您从 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
]
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1218 次 |
| 最近记录: |