当我配置gatsby-plugin-i18n
的pagesPaths
选项时,永远不会调用变压器gatsby-transformer-remark
。
module.exports = {
siteMetadata: {
title: 'example.com',
},
plugins: [
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'content',
path: `${__dirname}/src/content`
}
},
{
resolve: 'gatsby-transformer-remark',
options: {
plugins: [
{
resolve: 'gatsby-remark-responsive-iframe',
options: {
wrapperStyle: 'margin-bottom: 1rem'
}
},
'gatsby-remark-prismjs',
'gatsby-remark-copy-linked-files',
'gatsby-remark-smartypants',
{
resolve: 'gatsby-remark-images',
options: {
maxWidth: 1140,
quality: 90,
linkImagesToOriginal: false
}
}
]
}
},
{
resolve: 'gatsby-plugin-i18n',
options: {
langKeyDefault: 'en',
useLangKeyLayout: false,
prefixDefault: false
pagesPaths: ['/src/pages/', '/src/content/']
}
}
]
}
如果我的/src/content/
中有pagesPaths
,则该文件夹中的markdown文件不会通过备注进行处理,因此,我永远无法将自定义节点字段添加到此节点。内部类型为MarkdownRemark
的节点不存在:
exports.onCreateNode = ({ node, actions, getNode }) => {
const { createNodeField } = actions
switch (node.internal.type) {
case 'MarkdownRemark': {
const { permalink, layout } = node.frontmatter
const { relativePath } = getNode(node.parent)
let slug = permalink
if (!slug) {
slug = `/${relativePath.replace('.md', '')}/`
}
// Used to generate URL to view this content.
createNodeField({
node,
name: 'slug',
value: slug || ''
})
// Used to determine a page layout.
createNodeField({
node,
name: 'layout',
value: layout || ''
})
break
}
default: {
break
}
}
}
有人知道这里发生了什么吗?
我正在使用盖茨比2.18.17
。