I will talk about following technologies used.
Here is a the recap of the architecture in the previous article.
Gatsby is used to generate a static page, which is then deployed to Netlify. And Azure Function causes Netlify to rebuild the static page via build webhook.
I will go over each component one by one below.
It’s a static site generator using ReactJS (React hereafter) as UI template engine.
There are many static site generators out there, I picked it for two reasons.
Gatsby fetches Hacker News data via a publicly available Hacker News API (HN API hereafter) then merges it with React template to create a single HTML file.
Ryan’s plugin required Firebase credential to be passed but HN API is public thus required no credential.
Due to a default GitHub license issue, I could not fork, update, & publish my own plugin.
So the next option was to create a custom GraphQL data source, which exposes fetched HN data.
(I will go into more details on how it was implemented in a later blog post)
It’s a React library that lets you embed CSS in React (Styled Components Home).
I started using it out of a curiosity.
But then I realized that it made creating simple stylized React component with ease with familiar CSS syntax (React requires slightly different syntax,
class attribute, and need to camelize CSS styles with
lineHeight instead of
Another benefit I found is that I could name the container making the code readable (instead of using generic “div” or “span”) and intentional.
You can see that
storiesComponents is consisted of a story with rank, content, which contains body and meta data.
As mentioned in “Why?”, I used it to apply styles without an external CSS file keeping each component self-contained (but less flexible as I didn’t use theming functionality).
CSS in JS is very controversial so I won’t go into much details.
But you could read up on CSS in JS, and make your own decision 😉
Netlify is a web site hosting company, which makes deploying from GitHub very easy (& 😀 free 💰).
I deployed GitHub repo using similar steps I blogged about.
(Refer to my previous post Deploying Existing Create-React-App on GitHub to Netlify)
Netlify is aware that a project is a Gatsby site thus filling out many values for you (what command to run and what folder to deploy to production)
And also publishing to a master branch (you can set it to another branch) continuously deploys to production as Netlify creates a webhook on GitHub and runs the build automatically.
It’s sorta like a Web API you can invoke without requiring a server.
Here is an analogy I heard from somewhere (I think it was Scott Hanselman in one of the Azure related podcasts).
Building your own server to get something work done
– is like “building your own car” to get to one point to another
– You pay for car parts (server parts) and build costs
Deploying your site to a cloud
– is like “buying a car” (a server) – and you are responsible for maintaining it
Calling/invoking Azure Functions
– is like “renting a car” as you don’t take care of the car (server) yourself.
– You just want to go from one place to another (the purpose is to get a piece of work done without requiring a server).
AWS Lambda was pain in the butt as I just needed a simple job that runs every hour without much security concern.
It runs every hour doing a HTTPS POST request to the Netlify’s Build WebHook (Using an experimental PowerShell version of Azure Functions).
Full implementation (I mean really)
Azure Functions Schedule (runs every 60 minutes on the hour)
In this article, I’ve shown you tech stack used to build SHaNc.
Most of the decisions are based on familiarity and ease of use.
In following posts, I will go more into details
(e.g. How to implement a custom GraphQL data source for GatsbyJS).
Leave a feedback on GitHub.
Say hi on Twitter @SlightEdgeCoder.