小编mdu*_*bus的帖子

使用 MDX 在 Gatsby 博客中添加 featuresImage

我正在尝试在我的 Gatsby 博客上添加特色图片,但无法使其正常工作。我在这里和那里尝试了几件事情,但我一直收到此错误消息:Field "featuredImage" must not have a selection since type "String" has no subfields.

这是我的博客结构:

src
 |- images
   |- house.jpeg
 | - pages
   |- actualites
     |- house.mdx
Run Code Online (Sandbox Code Playgroud)

house.mdx有以下frontmatter:

---
title: House
path: /house
date: 2019-01-29
featuredImage: ../../images/house.jpeg
---
Run Code Online (Sandbox Code Playgroud)

gatsby-plugin看起来像这样:

plugins: [
    `gatsby-plugin-resolve-src`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `${__dirname}/src/images`,
      },
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `${__dirname}/src/pages`,
      },
    },
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-remark-images`,
            options: {
              maxWidth: 800, …
Run Code Online (Sandbox Code Playgroud)

graphql gatsby

7
推荐指数
1
解决办法
268
查看次数

从 Next JS 动态路由中的 URL 中删除语言

我在 NextJS 中有一个带有 next-i18next 的网站,除了页面之外的每个页面都必须翻译legal

这些legal页面是 Markdown 格式的,并且由于[legal].js页面及其中的getStaticPaths和 ,我启用了动态路由。getStaticProps

问题是,通过构建我的网站,我的法律页面会以该语言为前缀(此处en)。我想删除它,因为我不想翻译这些页面。

我在这里做错了什么?

多谢

文件夹结构:

pages
|- index.js
|- [legal].js
|- privacy-policy.mdx

Run Code Online (Sandbox Code Playgroud)

下一个-i18next.config.js

pages
|- index.js
|- [legal].js
|- privacy-policy.mdx

Run Code Online (Sandbox Code Playgroud)

[法律].js

module.exports = {
  i18n: {
    defaultLocale: 'en',
    locales: ['en'],
    fallbackLng: 'en',
    defaultNS: ['homepage', 'header', 'footer'],
    localeDetection: false,
  },
}
Run Code Online (Sandbox Code Playgroud)

构建输出:

动态页面中的语言输出

next.js next-i18next

5
推荐指数
1
解决办法
3135
查看次数

标签 统计

gatsby ×1

graphql ×1

next-i18next ×1

next.js ×1