【发布时间】:2022-01-13 22:50:46
【问题描述】:
所以我想弄清楚如何渲染我的博客文章内嵌的图像。我确实在顶部有一张精选图片,但无法弄清楚如何获取内联图片。
图片存储在src/images/
office-upgrade.md
---
title: "Office Upgrade"
image: ../images/office1.jpg
featured: false
author:
name: "jrock2004"
date: "2017-08-06"
tags:
- general
---
So, when I moved into our new house 3 yrs ago, my only requirement was I have my own office. In my last house I was stuck in the basement. When I made videos, I would get the jokes about living in my moms basement. As you can see, all the cords where just all over the place. It was just so bad.

盖茨比-config.md
plugins: [
'gatsby-plugin-postcss',
{
resolve: `gatsby-plugin-mdx`,
options: {
extensions: [`.mdx`, `.md`],
},
},
'gatsby-plugin-image',
'gatsby-plugin-sharp',
'gatsby-transformer-sharp',
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'images',
path: `${__dirname}/src/images/`,
},
__key: 'images',
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'pages',
path: './src/pages/',
},
__key: 'pages',
},
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: `gatsby-remark-images`,
options: {
maxWidth: 800,
},
},
],
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'posts',
path: `${__dirname}/src/posts/`,
},
__key: 'posts',
},
],
组件/post/index.tsx
<article className={`markdown mt-12 mx-auto ${image && 'w-11/12'}`}>
<MDXProvider components={components}>
<MDXRenderer>{body}</MDXRenderer>
</MDXProvider>
</article>
当我查看 DOM 时,这就是渲染的内容
<img src="images/office2.jpg" alt="Nightmare Cable Management">
我在这里做错了什么?
【问题讨论】:
标签: gatsby gatsby-image