{"id":15552,"date":"2021-06-15T20:22:23","date_gmt":"2021-06-15T20:22:23","guid":{"rendered":"https:\/\/www.patrickvhessman.com\/backend\/?p=15552"},"modified":"2021-06-15T23:49:18","modified_gmt":"2021-06-15T23:49:18","slug":"time-for-an-upgrade","status":"publish","type":"post","link":"https:\/\/www.patrickvhessman.com\/backend\/uncategorized\/time-for-an-upgrade\/","title":{"rendered":"Time for an Upgrade"},"content":{"rendered":"\n<p>As I&#8217;ve repeated throughout this site, I&#8217;m all about learning new web skills and technology. When I made the decision to enter this field in 2014 (after going to school for film, no less), I knew an appetite for learning was the only way forward. After all, the new hotness in the web development world is always changing. The tech stack at your workplace can&#8217;t be changed on a whim, so oftentimes I&#8217;d have to make demo projects to practice and more importantly, show off the new skills.<\/p>\n\n\n\n<p>My most recent study undertaking has been <a href=\"https:\/\/graphql.org\/\">GraphQL<\/a> after it was suggested to me at a job interview. After learning more about it, I found out it&#8217;s a major component of <a href=\"https:\/\/www.gatsbyjs.com\/\">Gatsby<\/a>, which had also been suggested to me in the past as a potential alternative for fighting with WordPress themes. After learning the basics of GraphQL from tutorials on its official website, I worked through two helpful Udemy courses: <a href=\"https:\/\/www.udemy.com\/course\/graphql-with-react-course\/\">GraphQL with React: The Complete Developers Guide<\/a> and <a href=\"https:\/\/www.udemy.com\/course\/gatsby-js-react-wordpress-graphql\/\">Gatsby JS: Build Gatsby static sites with React &amp; WordPress<\/a>. I was ready to put those skills to use.<\/p>\n\n\n\n<p>Since I like to periodically refresh my personal website anyways, I figured why not use them to upgrade it? A content management system would be great for easily updating page sections and adding new portfolio items. Plus, I wanted to add a blog. The previous setup of this site was mostly manual, a static React site that required a lot of hard coding for page content. From the outside it looked pretty, but under the hood it could be so much better.<\/p>\n\n\n\n<p>First off, I began with a <a href=\"https:\/\/www.gatsbyjs.com\/starters\/gatsbyjs\/gatsby-starter-default\/\">Gatsby starter<\/a> and set out to determine the exact needs of the site and the GraphQL queries it would involve. I&#8217;m quite partial to the design of this website, so I didn&#8217;t want to throw huge chunks out. Thus, it required some extra post types and custom fields for said posts. Regular pages inside WordPress would be fine for sections such as the Overview and About, but the Portfolio and Resume sections needed their own post types.<\/p>\n\n\n\n<p>My WordPress installation needed three plugins to accomplish this goal: <a href=\"https:\/\/wordpress.org\/plugins\/advanced-custom-fields\/\">Advanced Custom Fields<\/a>, <a href=\"https:\/\/wordpress.org\/plugins\/acf-to-rest-api\/\">ACF to REST<\/a>, and <a href=\"https:\/\/wordpress.org\/plugins\/custom-post-type-ui\/\">Custom Post Types UI<\/a>. Custom Post Types allowed me to create the specialized post types, Advanced Custom Fields let me populate said new post types with needed fields (such as a URL field for the portfolio projects), and ACF to Rest made said fields accessible in GraphQL queries. All in all, the GraphQL queries ended up looking like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/custom-graph-ql-query-1.png\"><img loading=\"lazy\" width=\"810\" height=\"340\" src=\"https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/custom-graph-ql-query-1.png\" alt=\"\" class=\"wp-image-15556\" srcset=\"https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/custom-graph-ql-query-1.png 810w, https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/custom-graph-ql-query-1-300x126.png 300w, https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/custom-graph-ql-query-1-768x322.png 768w\" sizes=\"(max-width: 810px) 100vw, 810px\" \/><\/a><\/figure>\n\n\n\n<p>From there, it was just a matter of linking up the various sections\/components of the page to corresponding queries to pull the designated content.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/overview-query.png\"><img loading=\"lazy\" width=\"751\" height=\"307\" src=\"https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/overview-query.png\" alt=\"\" class=\"wp-image-15557\" srcset=\"https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/overview-query.png 751w, https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/overview-query-300x123.png 300w\" sizes=\"(max-width: 751px) 100vw, 751px\" \/><\/a><\/figure>\n\n\n\n<p>The custom post types, of course, required a more specified GraphQL query:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/resumeCode.png\"><img loading=\"lazy\" width=\"677\" height=\"717\" src=\"http:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/resumeCode.png\" alt=\"\" class=\"wp-image-15576\" srcset=\"https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/resumeCode.png 677w, https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/resumeCode-283x300.png 283w\" sizes=\"(max-width: 677px) 100vw, 677px\" \/><\/a><\/figure>\n\n\n\n<p>The most complicated part of this entire process was incorporation of regular blog posts into this site. That was the entire aim of redoing the site in Gatsby, after all. Unlike the components that only needed to query a single page or a simple custom post type, the queries needed for creating individual pages for the blog posts couldn&#8217;t be done inside StaticQuery. For that, I had to utilize the <em>gatsby-node.js<\/em> file, which is included in installations of Gatsby. In this file, I had to perform a query for the blog posts, then use the <em>createPage<\/em> function to create a route for each blog post and link it to the post template file.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/gatsby-node.png\"><img loading=\"lazy\" width=\"617\" height=\"860\" src=\"http:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/gatsby-node.png\" alt=\"\" class=\"wp-image-15577\" srcset=\"https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/gatsby-node.png 617w, https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/gatsby-node-215x300.png 215w\" sizes=\"(max-width: 617px) 100vw, 617px\" \/><\/a><\/figure>\n\n\n\n<p>And, voila:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/blog-post-working.png\"><img loading=\"lazy\" width=\"1024\" height=\"712\" src=\"http:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/blog-post-working-1024x712.png\" alt=\"\" class=\"wp-image-15578\" srcset=\"https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/blog-post-working-1024x712.png 1024w, https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/blog-post-working-300x208.png 300w, https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/blog-post-working-768x534.png 768w, https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/blog-post-working.png 1272w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Lastly, I wanted to create a pagination component for the home page. This component could mostly work with a Static Query, but it needed some fiddling to only display the specified number of posts at a time. I accomplished this by feeding the result of the posts query into the component and manipulating the array to only show two posts at a time. When the back and forward controls on the component are used, the start and end indexes on the slice function operating on the main array are changed:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/paginated-functions.png\"><img loading=\"lazy\" width=\"666\" height=\"297\" src=\"http:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/paginated-functions.png\" alt=\"\" class=\"wp-image-15579\" srcset=\"https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/paginated-functions.png 666w, https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/paginated-functions-300x134.png 300w\" sizes=\"(max-width: 666px) 100vw, 666px\" \/><\/a><\/figure>\n\n\n\n<p>And here is the result:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"http:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/blog-list-component-1.png\"><img loading=\"lazy\" width=\"1024\" height=\"534\" src=\"http:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/blog-list-component-1-1024x534.png\" alt=\"\" class=\"wp-image-15581\" srcset=\"https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/blog-list-component-1-1024x534.png 1024w, https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/blog-list-component-1-300x157.png 300w, https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/blog-list-component-1-768x401.png 768w, https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/blog-list-component-1.png 1265w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>I am planning more upgrades for the blog component of this site in the future, likely when I have more blog posts to manage\/catalog. Learning Gatsby was an interesting experience, and I&#8217;m always excited to add another arrow to my quiver of skills. If you&#8217;re interested in seeing the code in depth, check out the <a href=\"https:\/\/github.com\/PatrickVHessman\/personal-website-2021\/tree\/master\">website&#8217;s GitHub repo<\/a>. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I wanted to learn Gatsby, I wanted to update my website. Why not kill two birds with one developmental stone?<\/p>\n","protected":false},"author":1,"featured_media":15582,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"acf":{"description":"I wanted to learn Gatsby, I wanted to update my website. Why not kill two birds with one developmental stone?"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Time for an Upgrade - Patrick V. Hessman<\/title>\n<meta name=\"description\" content=\"I wanted to learn Gatsby, I wanted to update my website. Why not kill two birds with one developmental stone?\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.patrickvhessman.com\/backend\/uncategorized\/time-for-an-upgrade\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Time for an Upgrade - Patrick V. Hessman\" \/>\n<meta property=\"og:description\" content=\"I wanted to learn Gatsby, I wanted to update my website. Why not kill two birds with one developmental stone?\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.patrickvhessman.com\/backend\/uncategorized\/time-for-an-upgrade\/\" \/>\n<meta property=\"og:site_name\" content=\"Patrick V. Hessman\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-15T20:22:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-15T23:49:18+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/1_G9aVAI3aezHLw_JsiCfB1Q.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"500\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.patrickvhessman.com\/backend\/#website\",\"url\":\"https:\/\/www.patrickvhessman.com\/backend\/\",\"name\":\"Patrick V. Hessman\",\"description\":\"Front End\/Full Stack Developer\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.patrickvhessman.com\/backend\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.patrickvhessman.com\/backend\/uncategorized\/time-for-an-upgrade\/#primaryimage\",\"inLanguage\":\"en\",\"url\":\"https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/1_G9aVAI3aezHLw_JsiCfB1Q.jpeg\",\"contentUrl\":\"https:\/\/www.patrickvhessman.com\/backend\/wp-content\/uploads\/2021\/06\/1_G9aVAI3aezHLw_JsiCfB1Q.jpeg\",\"width\":1000,\"height\":500},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.patrickvhessman.com\/backend\/uncategorized\/time-for-an-upgrade\/#webpage\",\"url\":\"https:\/\/www.patrickvhessman.com\/backend\/uncategorized\/time-for-an-upgrade\/\",\"name\":\"Time for an Upgrade - Patrick V. Hessman\",\"isPartOf\":{\"@id\":\"https:\/\/www.patrickvhessman.com\/backend\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.patrickvhessman.com\/backend\/uncategorized\/time-for-an-upgrade\/#primaryimage\"},\"datePublished\":\"2021-06-15T20:22:23+00:00\",\"dateModified\":\"2021-06-15T23:49:18+00:00\",\"author\":{\"@id\":\"https:\/\/www.patrickvhessman.com\/backend\/#\/schema\/person\/93a1cde1c05f0762553b411a77f50814\"},\"description\":\"I wanted to learn Gatsby, I wanted to update my website. Why not kill two birds with one developmental stone?\",\"breadcrumb\":{\"@id\":\"https:\/\/www.patrickvhessman.com\/backend\/uncategorized\/time-for-an-upgrade\/#breadcrumb\"},\"inLanguage\":\"en\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.patrickvhessman.com\/backend\/uncategorized\/time-for-an-upgrade\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.patrickvhessman.com\/backend\/uncategorized\/time-for-an-upgrade\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.patrickvhessman.com\/backend\/\",\"url\":\"https:\/\/www.patrickvhessman.com\/backend\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@id\":\"https:\/\/www.patrickvhessman.com\/backend\/uncategorized\/time-for-an-upgrade\/#webpage\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.patrickvhessman.com\/backend\/#\/schema\/person\/93a1cde1c05f0762553b411a77f50814\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.patrickvhessman.com\/backend\/#personlogo\",\"inLanguage\":\"en\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1026d01b58eedd3dd1c7db215b7e8f29?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1026d01b58eedd3dd1c7db215b7e8f29?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"url\":\"https:\/\/www.patrickvhessman.com\/backend\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/www.patrickvhessman.com\/backend\/wp-json\/wp\/v2\/posts\/15552"}],"collection":[{"href":"https:\/\/www.patrickvhessman.com\/backend\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.patrickvhessman.com\/backend\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.patrickvhessman.com\/backend\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.patrickvhessman.com\/backend\/wp-json\/wp\/v2\/comments?post=15552"}],"version-history":[{"count":4,"href":"https:\/\/www.patrickvhessman.com\/backend\/wp-json\/wp\/v2\/posts\/15552\/revisions"}],"predecessor-version":[{"id":15584,"href":"https:\/\/www.patrickvhessman.com\/backend\/wp-json\/wp\/v2\/posts\/15552\/revisions\/15584"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.patrickvhessman.com\/backend\/wp-json\/wp\/v2\/media\/15582"}],"wp:attachment":[{"href":"https:\/\/www.patrickvhessman.com\/backend\/wp-json\/wp\/v2\/media?parent=15552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.patrickvhessman.com\/backend\/wp-json\/wp\/v2\/categories?post=15552"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.patrickvhessman.com\/backend\/wp-json\/wp\/v2\/tags?post=15552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}