Gatsby MDX Slug不可激活,名称中包含目录
创建的slug包含根目录,因此将slug传递给Gatsby MDX Slug不可激活,名称中包含目录,gatsby,gatsby-plugin,gatsby-plugin-mdx,Gatsby,Gatsby Plugin,Gatsby Plugin Mdx,创建的slug包含根目录,因此将slug传递给将被破坏。 页面已创建,但链接到页面的slug不必要地包含包含文件夹,无论是帖子还是页面 可导航页面包括: localhost:8000/test-mdx-1/ localhost:8000/posts/test-mdx-2/ localhost:8000/test-mdx-3/ 文件位置为: ./src/posts/test-mdx-1.mdx ./src/pages/posts/test-mdx-2.mdx
将被破坏。
页面已创建,但链接到页面的slug不必要地包含包含文件夹,无论是帖子还是页面
可导航页面包括:
localhost:8000/test-mdx-1/
localhost:8000/posts/test-mdx-2/
localhost:8000/test-mdx-3/
文件位置为:
./src/posts/test-mdx-1.mdx
./src/pages/posts/test-mdx-2.mdx
./src/pages/test-mdx-3.mdx
**问题产生的鼻涕虫**
slug: "posts/test-mdx-1/"
slug: "pages/posts/test-mdx-2/"
slug: "pages/test-mdx-3/"
**期望结果**
slug: "test-mdx-1/"
slug: "posts/test-mdx-2/"
slug: "test-mdx-3/"
使用插件:
{
resolve: 'gatsby-plugin-mdx',
options: {
extensions: [`.mdx`],
gatsbyRemarkPlugins: [
{
resolve: 'gatsby-remark-images',
options: { maxWidth: 600 },
},
{
resolve: `gatsby-remark-responsive-iframe`,
options: {
wrapperStyle: `margin-bottom: 1.0725rem`,
},
},
],
},
},
// ** as per tutorial
{
resolve: 'gatsby-source-filesystem',
options: {
name: `pages`,
path: `${__dirname}/src/pages`,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: `posts`,
path: `${__dirname}/src/posts`,
},
},
// ** Create mdx pages outside of ./src/pages directory
{
resolve: 'gatsby-plugin-page-creator',
options: {
path: `${__dirname}/src/posts`,
},
},
已排序-只需要1个gatsby源文件系统, 已将所有.mdx文件移动到./src/posts gatsby-config.js
...
{
resolve: 'gatsby-plugin-mdx',
options: {
extensions: [`.mdx`],
gatsbyRemarkPlugins: [
{
resolve: 'gatsby-remark-images',
options: { maxWidth: 600 },
},
{
resolve: `gatsby-remark-responsive-iframe`,
options: {
wrapperStyle: `margin-bottom: 1.0725rem`,
},
},
],
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: `posts`,
path: `${__dirname}/src/posts`,
},
},
// ** Create mdx pages outside of ./src/pages directory
{
resolve: 'gatsby-plugin-page-creator',
options: {
path: `${__dirname}/src/posts`,
},
},
...