New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reference style links in MDX broken in static builds #30905
Comments
Thanks for the issue and reproduction! I'm also seeing this following your steps. Unfortunately, at this time I'm not sure why that might happen. Maybe it's a bug in the underlying packages such as |
It looks like the path prefix is added in The following change should fix this: async function transformer(markdownAST) {
// Ensure relative links include `pathPrefix`
- visit(markdownAST, `link`, node => {
+ visit(markdownAST, [`link`, `definition`], node => {
if (
node.url &&
node.url.startsWith(`/`) &&
!node.url.startsWith(`//`)
) { I can create a PR for this change if you want. |
Yeah, looking at https://astexplorer.net/#/gist/e6f30d6ee1d24d361ad6baa6e8cd8c62/6e86918d2c1fcb1c964c9c5694e598c1f63ed447 adding A PR would be highly appreciated! |
This addresses the issue brought up in gatsbyjs#30905
PR created: #30967 |
Description
When building the static assets for a site with MDX content that uses reference-style links and a site prefix, the site prefix does not get appended to the link destination for internal links.
Steps to reproduce
npm init gatsby
gatsby-config.js
and add a path prefix1 module.exports = { + 2 pathPrefix: `/my-site/`, 3 siteMetadata: { 4 title: "My Gatsby Site", 5 }, 6 plugins: [ 7 "gatsby-plugin-mdx", 8 { 9 resolve: "gatsby-source-filesystem", 10 options: { 11 name: "pages", 12 path: "./src/pages/", 13 }, 14 __key: "pages", 15 }, 16 ], 17 };
src/pages/test.mdx
) with the following content:npm run build --prefix-paths
npm run serve
Expected result
The first link will have the destination:
http://localhost:9000/my-site/path/to/page/
✅The second link will have the destination:
http://localhost:9000/my-site/path/to/page/
✅Actual result
The first link has the destination:
http://localhost:9000/my-site/path/to/page/
✅The second link has the destination:
http://localhost:9000/path/to/page/
❌Environment
The text was updated successfully, but these errors were encountered: