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

Simplify repoRootPath option #45

Merged
merged 2 commits into from
Aug 9, 2019
Merged

Simplify repoRootPath option #45

merged 2 commits into from
Aug 9, 2019

Conversation

colebemis
Copy link
Contributor

@colebemis colebemis commented Aug 9, 2019

Problem

We currently require users to specify a repoRootPath option in gatsby-config.js in order to generate GitHub edit links for each page. repoRootPath is the absolute path to the root of the users git repository. Since the path needs to be absolute, users have to use Node.js functions like process.cwd() and path.resolve() to compute the path. This can be confusing for less technical users.

Solution

I simplified repoRootPath so it now accepts a relative path instead of an absolute path. I also set the default repoRootPath to '.'.

repoRootPath can accept a relative path because the current working directory when executing gatsby-node.js is the root of the user's Gatsby site. So we can use process.cwd() and path.resolve() in gatsby-node.js to compute the absolute path to the root of their git repository given a relative path.

Impact

If a user's site is located at the root of their git repository, they won't have to specify repoRootPath. If their site is in a subdirectory, they can specify the relative path to the root with a string instead of using process.cwd() and path.resolve().

@colebemis colebemis requested a review from emplums August 9, 2019 17:23
@vercel
Copy link

vercel bot commented Aug 9, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

Latest deployment for this branch: https://doctocat-git-update-repo-root-path.primer.now.sh

Copy link
Contributor

@emplums emplums left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, this experience is much better! 🙌

@colebemis colebemis merged commit ef7b78f into master Aug 9, 2019
@colebemis colebemis deleted the update-repo-root-path branch August 19, 2019 16:25
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.

2 participants