-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[v2] fileAbsolutePath starts from the file system root instead of project root #7463
Comments
Hello, I think an absolute paths starts to the system's root, so the real problem were on version 1.0. |
@grallc I would have expected the absolute path to start from the project root otherwise you'd have all sorts of problems when building in different environements. Regardless, if this change is intended, it would be nice if it were documented somewhere. One thing I have noticed is that During build, the path is what it used to be (relative to the project root) but when running |
I had time today to investigate this some more. It turns out that import { dirname, relative } from "path";
let fileRelPath = relative(absoluteFilePathPrefix, dirname(fileAbsolutePath)); …where When this code is run during the server build, Something has changed between Gatsby v1 and v2 which means that In my case, I ended up fixing it with a hacky workaround: if (fileRelPath.includes("pages")) {
fileRelPath = fileRelPath.split(absoluteFilePathPrefix)[1].replace(/^\/+/g, "");
} |
Old issues will be closed after 30 days of inactivity. This issue has been quiet for 20 days and is being marked as stale. Reply here or add the label "not stale" to keep this issue open! |
This issue is being closed due to inactivity. Is this a mistake? Please re-open this issue or create a new issue. |
Ugh. I'd love to see some action on this since I would prefer to not leak private information about build machines to our public site. |
Description
We have some code that creates a hierarchy based on the folder / file structure of Markdown files. We use this to create an index page of all help articles and then show the breadcrumbs when you visit an article based on frontmatter in the parent folder’s index.md file.
Previously, in Gatsby v1,
allMarkdownRemark.edges[n].node.fileAbsolutePath
would contain the absolute path to the Markdown file relative to the Gatsby root. For example:Now, in Gatsby v2, it looks like
allMarkdownRemark.edges[n].node.fileAbsolutePath
contains the absolute path to the Markdown file, relative to the file system. For example:Expected result
The path contained in
allMarkdownRemark.edges[n].node.fileAbsolutePath
should be relative to the root of the Gatsby project.Actual result
The path contained in
allMarkdownRemark.edges[n].node.fileAbsolutePath
is relative to the root of my specific file system.Environment
File contents (if changed)
gatsby-config.js
:package.json
:gatsby-node.js
:gatsby-browser.js
: N/Agatsby-ssr.js
: N/AThe text was updated successfully, but these errors were encountered: