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

feat(blog): add post for office of natural resources #11561

Merged
merged 9 commits into from
Feb 6, 2019

Conversation

brentryanjohnson
Copy link
Contributor

  • Blog post submission for government open data site to gatsbyjs

@brentryanjohnson brentryanjohnson requested a review from a team February 5, 2019 07:57
@DSchau DSchau changed the title Blog post submission feat(blog): add post for office of natural resources Feb 5, 2019
Copy link
Contributor

@DSchau DSchau left a 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.
Copy link
Contributor

@DSchau DSchau Feb 5, 2019

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).

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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
Copy link
Contributor

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

Suggested change
date: 2019-02-05
date: 2019-02-08

(will also need to re-name the file if that's OK with you both!)

Copy link
Contributor Author

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`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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)) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

@DSchau DSchau Feb 5, 2019

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!

Copy link
Contributor Author

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.


#### 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.
Copy link
Contributor

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?

Copy link
Contributor

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!

Copy link
Contributor Author

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.
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@brentryanjohnson
Copy link
Contributor Author

@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.

@DSchau
Copy link
Contributor

DSchau commented Feb 5, 2019

@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!

@brentryanjohnson
Copy link
Contributor Author

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.

@brentryanjohnson
Copy link
Contributor Author

I resolved that merge conflict and removed Jeff's entry from authors.yml since we removed him from the author front matter @DSchau.

Copy link
Contributor

@DSchau DSchau left a 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!

@DSchau DSchau merged commit d9e2883 into gatsbyjs:master Feb 6, 2019
@gatsbot
Copy link

gatsbot bot commented Feb 6, 2019

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:

  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. (Currently we’ve got a couple t-shirts available, plus some socks that are really razzing our berries right now.)
  2. We just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. Accept the invite by visiting https://github.com/orgs/gatsbyjs/invitation. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

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!

@brentryanjohnson brentryanjohnson deleted the gov-gatsby-blog-post branch February 7, 2019 00:22
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

2 participants