-
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
feat(blog): add post for office of natural resources #11561
Conversation
brentryanjohnson
commented
Feb 5, 2019
- Blog post submission for government open data site to gatsbyjs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good--left a number of comments! The only blocker is the author
field which currently only supports a single author.
|
||
A few months ago, our small team at the Office of Natural Resources Revenue (ONRR) decided we needed to refactor our [open-data website](https://revenuedata.doi.gov/). We knew we were in for a massive undertaking, as the site was originally built with the static-site generator [Jekyll](https://jekyllrb.com/), with significant custom coding to furnish bespoke features, automate data updates, and compile and deploy the site with [18F's](https://18f.gsa.gov/) fantastic static-site hosting service, [Federalist](https://federalist.18f.gov/). | ||
|
||
As covered in our [first post in this series](/homepage-revamp/), we were simultaneously scoping a redesign of our homepage. Rebuilding the homepage would allow us to test some of our assumptions about how to address obstacles in our existing workflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll have to make these links (/homepage-revamp/
) absolute (e.g. prepend the original blog post URL).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops! Yes, thank you.
title: "How we're migrating a government open data site to Gatsby" | ||
date: 2019-02-05 | ||
authors: | ||
- Ryan Johnson |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't currently support multiple authors :/ Is there a primary author on this post we could use? Otherwise we'll have to implement that feature to ship this blog post.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can change it to reflect a primary author.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We did modify the gatsby-starter-blog to support multiple authors when we shipped our blog, but I'm not quite happy with the way I'm doing it now (I describe why over here: https://brentryanjohnson.com/content-design-dry/)
@@ -0,0 +1,237 @@ | |||
--- | |||
title: "How we're migrating a government open data site to Gatsby" | |||
date: 2019-02-05 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's schedule this for Friday
date: 2019-02-05 | |
date: 2019-02-08 |
(will also need to re-name the file if that's OK with you both!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem.
|
||
As mentioned above, we use [Federalist](https://federalist.18f.gov/) to build and deploy the site. Federalist builds out every branch in our GitHub repository, so we can preview the changes before we merge them. | ||
|
||
We encountered an issue with the Federalist preview URLs and relative links and assets. Gastby solves this by using a `pathPrefix` variable in `gastby-config.js` and a custom component named `Link`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We encountered an issue with the Federalist preview URLs and relative links and assets. Gastby solves this by using a `pathPrefix` variable in `gastby-config.js` and a custom component named `Link`. | |
We encountered an issue with the Federalist preview URLs and relative links and assets. Gatsby solves this by using a `pathPrefix` variable in `gastby-config.js` and a custom component named `Link`. |
|
||
let path = window.location.pathname | ||
|
||
if (path.includes("/explore") && usStateIds.includes(statePathId)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note that this snippet is a little confusing. I'm presuming usStateIds
is somewhere above the scope of this function?
Maybe just hard code an array for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's code fenced isn't it? I'm not sure why Jeff chose this particular snippet of code to represent this work around. I'm hesitant to change it, since we published it this way on our blog already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really see what code fencing has to do with this?
I mean that usStateIds
and statePathId
are not in the scope of this snippet, so it's harder to follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see...I thought you meant the actual logic wouldn't work!
I guess I could link to the full code here as a compromise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah! That would be great!
The idea comes across, you're basically extending the internal loader to be aware of additional paths, but I can see how it could be confusing when it's broken out of context like this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see...that's an array of all 50 states and DC, so it would have taken up some serious screen real estate. I added a link to the repo for that one.
docs/blog/2019-02-06-government-open-data-site-with-gatsby/index.md
Outdated
Show resolved
Hide resolved
|
||
#### Page URL issue | ||
|
||
When Gatsby builds the site, it creates a `public` directory for all required site assets. We copied this directory to a `gatsby-public` folder for the Jekyll build to use. However, we didn't want our URLs to include `gatsby-public`, so we needed to add a permalink attribute to our pages' front matter to override the default path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General question - why not use the other approach (which seems simpler?) of just re-using the public
folder for the Jekyll build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guessing you want a clear way to avoid possible duplicates or one build process conflicting with the other? Where is the Jekyll
build in gatsby-public
?
Also - this is just a question out of curiosity, not a blocker for this PR at all!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll see if @master12 wants to reply to this one. :)
|
||
## Challenges during rebuild | ||
|
||
While our experience refactoring the homepage was largely positive, we have faced some challenges migrating to Gatsby. Some of those challenges are inherent in refactoring, caused by maintaining two codebases and build processes simultaneously. Others are perhaps due to the relatively new emergence of Gatsby itself, which is actively being worked on and upgraded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gatsby isn't really all that new! We'd love any feedback on areas we can improve upon, here re: challenges you faced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are experiencing relatively long build times, @DSchau. Part of the reason is that we're still compiling two separate codebases, but the build time increased a lot when we expanded our graphql schema. We hope eliminating the Jekyll build, and upgrading our Gatsby version, will help mitigate this problem, but we're more than happy to hear tips from Gatsby folks on how we might improve the build.
…ex.md Co-Authored-By: brentryanjohnson <32855580+brentryanjohnson@users.noreply.github.com>
…hnson/gatsby into gov-gatsby-blog-post
@DSchau I pushed additional commits with the changes you suggested. Let me know if I missed anything...I left the directory name change to you, because I thought that might be easier on your end. |
@brentryanjohnson thanks so much! Made that change. I'll give this another once-over, and if it looks good to go I'll just merge. We have some tooling in place, so we can merge future posts, and they'll just go live when the build date is the date of the post! |
Nice! Thank you for the opportunity to share our experience using Gatsby in the federal government. And we're always happy to hear what we could be doing better. |
I resolved that merge conflict and removed Jeff's entry from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merging. This should go live this Friday; thanks!
Holy buckets, @brentryanjohnson — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! |