我有从git来源传入的MDX文件的节点。我正在使用Graphql处理各个MDX文件的生成路径
这里是所有MDX节点
{
"data": {
"allMdx": {
"edges": [
{
"node": {
"fields": {
"slug": "/section-1/parent page adjacent/"
},
"frontmatter": {
"title": "Test file"
},
"parent": {
"relativeDirectory": "section-1"
},
"fileAbsolutePath": "/gatsby-source-git/gitData/section-1/parent page adjacent.mdx"
}
},
{
"node": {
"fields": {
"slug": "/section-1/parent page/"
},
"frontmatter": {
"title": "root page"
},
"parent": {
"relativeDirectory": "section-1"
},
"fileAbsolutePath": "/gatsby-source-git/gitData/section-1/parent page.mdx"
}
},
{
"node": {
"fields": {
"slug": "/section-1/parent page/child one 1/"
},
"frontmatter": {
"title": "child one 1"
},
"parent": {
"relativeDirectory": "section-1/parent page"
},
"fileAbsolutePath": "/gatsby-source-git/gitData/section-1/parent page/child one 1.mdx"
}
},
{
"node": {
"fields": {
"slug": "/section-1/parent page/child one 1/sub child one 1/"
},
"frontmatter": {
"title": "sub child one 1"
},
"parent": {
"relativeDirectory": "section-1/parent page/child one 1"
},
"fileAbsolutePath": "/gatsby-source-git/gitData/section-1/parent page/child one 1/sub child one 1.mdx"
}
}
],
}
}
}
我正在尝试从当前活动文件夹中获取MDX文件,而不是从父文件夹中获取所有MDX文件
假设活动文件夹为第1部分
我只打算获取父页面.mdx和父页面相邻.mdx,而不是嵌套文件夹中的子页面
到目前为止,我已经尝试在过滤器中使用正则表达式
allMdx(filter: {fileAbsolutePath: {regex: "/section-1/*//"}}) {}
最终,我打算创建一个嵌套MDX的树结构,该结构与这种方法相去甚远