-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add built in slug for gatsby-plugin-mdx (#25767)
* initial slug query * initial commit for slug, behavior not ideal * initial commit, not ideal behavior * undo gatsby-dev in packagejson * should be nullable * use relative path from context node instead * use relative path from context node instead * with relative path we don't need to slugify slashes * add whitespace * better naming * add another test case * use resolvable extensions list * add additional tests * fix typo in test * use path for parsing instead * can be const * fix test typos * add minor comment * make some minor changes to remove try/catch Co-authored-by: Laurie Barth <laurie@LauriesrkLaptop.fios-router.home>
- Loading branch information
LB
and
Laurie Barth
committed
Jul 16, 2020
1 parent
e95b876
commit c82569f
Showing
9 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is to add another source page for slugification. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react' | ||
import { graphql } from 'gatsby' | ||
|
||
const ListPage = ({ data }) => { | ||
const anotherPage = data.another.nodes[0] | ||
const blogPage = data.blog.nodes[0] | ||
const aboutPage = data.complex.nodes[0] | ||
const embedPage = data.embed.nodes[0] | ||
|
||
|
||
return ( | ||
<div> | ||
<div data-testid="mdx-slug">{anotherPage.slug}</div> | ||
<div data-testid="md-slug">{blogPage.slug}</div> | ||
<div data-testid="complex-slug">{aboutPage.slug}</div> | ||
<div data-testid="embed-slug">{embedPage.slug}</div> | ||
|
||
</div> | ||
) | ||
} | ||
|
||
export const query = graphql` | ||
{ | ||
another: allMdx(filter: {slug: {eq: "another"}}) { | ||
nodes { | ||
slug | ||
} | ||
} | ||
blog: allMdx(filter: {slug: {eq: "my-blog"}}) { | ||
nodes { | ||
slug | ||
} | ||
} | ||
complex: allMdx(filter: {slug: {eq: "about/"}}) { | ||
nodes { | ||
slug | ||
} | ||
} | ||
embed: allMdx(filter: {slug: {eq: "about/embedded"}}) { | ||
nodes { | ||
slug | ||
} | ||
} | ||
} | ||
` | ||
export default ListPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is a page that should include a slash slug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This should be an about page we can access with a nested slug. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Let's see if we can generate a slug for this too |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c82569f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi all,
Probably this PR isn't the source of the problem I found, but since is one of the last commits related on the last releases I am posting here in case…
Upgrading
@mdx-js/mdx
and@mdx-js/react
from1.6.10
into1.6.11
andgatsby-plugin-mdx
from1.2.26
into1.2.27
, since I am usingcreateMDXNode
fromgatsby-plugin-mdx/utils/create-mdx-node
I started to have a loop of errors likeDowngrading to the previous (patch) version, everything works well again. Maybe isn't safe to use
create-mdx-node
? In that case, is there a better way to create MDS nodes from an internal node?I can open a new issue In any case.
Thanks in advance,