-
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
Path attribute in .md front-matter should be relative by default? #221
Comments
Hmmm... interesting point. I don't have a great intuition for this as I don't regularly hard-code paths in markdown files (part of my reason for wanting to derive urls from the directory position ;-)). @gatsbyjs/gatsby-core-maintainers any thoughts? |
(there's also I should note the poorly documented rewritePath where you can programmatically rewrite paths to remove leading values from the path which is what I do on my blog) |
That’ll probably work just fine for my needs. Thanks! Edit: Adding this to app.js works exactly as I need it to. But is there a way to remove the hard-coded “writes” parent directory name?
|
Coming from Jekyll, I liked being able to separate out pages from posts in different directories and you could have a permalink option set in the site's config that would be applied to anything in the post directory. With gatsby's focus on providing the minimal feature set and relying on plug-ins to fill in the gaps, I think building out a plug-in with rewritePath would be a good solution. |
@kylegach hard coded where? In the parsed file info? @michaeljdeeb great point. I'm going to be working on fine-tuning/filling out the API + adding a plugin architecture soon so yeah, someone could create a plugin easily enough to add this sort of functionality. |
Hard-coded in that snippet I included. Ideally, I could replace “writes” with some representation of the parent of |
Ah ok. Yeah |
It seems that #223 would make this a moot issue. Or rather, it shows that I had an incorrect understanding of the way the path is intended to work in front-matter. |
Yeah I think defaulting to paths that are relative to the site root is the
|
* Made componentWithMDXScope a no-op. It is deprecated and doesn't need to be used any more. MDXRenderer is still required for previous uses that required it. * Scopes are now imported via custom webpack loader - TODO: rename mdx-scopes to the loaders dir * Scopes are now merged into a single scope and injected into wrapRootElement on both SSR and Browser renders * Querying code.scope is now a no-op - No files are written when this happens * Relative path import support is added to all MDX Nodes closes gatsbyjs#214 gatsbyjs#202 gatsbyjs#133
This is a suggestion, not a bug.
Given that one of the project’s goals is:
...it seems odd that the path attribute in the front-matter of an index.md file is always treated as absolute.
Imagine I have a directory structure:
And the front-matter of
/pages/writes/1-hello-world/index.md
includes:(note the lack of starting “/”)
Based on the goal quoted above, I'd expect the resulting URL to be
/writes/hello-world
. Currently, though, the resulting URL is/hello-world
.I realize I can simply leave off the path attribute (which results in
/writes/1-hello-world
), but I like using a preceding number or date to keep the pages in the correct order in the filesystem, and I would like that number or date to not be in the URL. Right now, the workaround is to add a path like “writes/hello-world”.For people that like the current behavior, using an absolute instead of relative path could provide that.
I’m just diving into this stuff, but if someone can point me in the right direction, I’ll try to investigate further toward an eventual PR.
I also realize this is breaking change, so maybe it should just stay as-is.
The text was updated successfully, but these errors were encountered: