Skip to content
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

Verifying that path strings are prepended a forward slash #223

Merged
merged 2 commits into from Apr 9, 2016
Merged

Verifying that path strings are prepended a forward slash #223

merged 2 commits into from Apr 9, 2016

Conversation

michaeljdeeb
Copy link
Contributor

Some funny things can occur if the path variable is improperly set in the front matter of a page.

This will check that all path strings are prepended with a forward slash.

Some interesting things to note, possibly for documentation or to improve upon the check.

  • No additional testing was added, but this fix passes npm test
  • This checking mechanism only works for gatsby build or the initial launch of gatsby develop (not thrown during hot reloading)
  • If your pages are structured similarly to the starter-blog, not having a forward slash at the end of your path string will cause files that aren't index to appear outside the folder with the folder name appended to them.
    • Ex. /pages/2015-05-01-hello-world/salty_egg.jpg would become /hello-worldsalty_egg.jpg if path were set to /hello-world
    • Opted not to check for this as someone may want a page such as 404.md to have the path /404.html for GitHub Pages.

@KyleAMathews KyleAMathews merged commit 6dc8bf4 into gatsbyjs:master Apr 9, 2016
@KyleAMathews
Copy link
Contributor

Merged this, thanks! These sorts of invariant run-time checks are worth a 1000 Stackoverflow answers :-) Basically any time there's a question on something here or elsewhere that we can add an automated check for we should.

I tweaked the messaging a bit and added a link in the message here (eventually we'll have actual doc pages that we can link to) in 2856acc

The output now looks like:

Invariant Violation:
          Paths must be prepended with a forward slash. You set the path to
          "hello-world/" in "2015-05-01-hello-world/index.md" but instead it should be "/hello-world/"

          See http://bit.ly/1qeNpdy for more.

Let me know what you think.

@michaeljdeeb
Copy link
Contributor Author

That looks great.

Linking to this PR is a great idea for the time being.

@jlengstorf
Copy link
Contributor

Hiya @michaeljdeeb! 👋

This is definitely late, but on behalf of the entire Gatsby community, I wanted to say thank you for being here.

Gatsby is built by awesome people like you. Let us say “thanks” in two ways:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. (We’ve got t-shirts and hats, plus some socks that are really razzing our berries right now.)
  2. If you’re not already part of it, we just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. You’ll receive an email shortly asking you to confirm. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If you have questions, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again! 💪💜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants