Skip to content

Instantly share code, notes, and snippets.

View diveddie's full-sized avatar
💭
const [coffee, setCoffee] = useState(true)

Eddie Hudson diveddie

💭
const [coffee, setCoffee] = useState(true)
View GitHub Profile
@diveddie
diveddie / README.md
Created February 8, 2020 19:25
Code Test for Theorem

This project was created using the Webstorm Node boilerplate, but you should be able to get it up and running in pretty much any code editor. I used Node v10.15.3. The only dependency for this project is Jasmine, which is what I used for the unit testing. Here is a step-by-step to get up and running to test this project.

To get started with Jasmine, taken from (https://jasmine.github.io/pages/getting_started.html):

  • Add Jasmine to your package.json: npm install --save-dev jasmine
const https = require('https');
const follow = function (url) {
url = url.indexOf('?')!== -1 ? url.replace(/\?/,'.json?') : url+'.json';
https.get(url, function (res) {
let raw = "";
res.on('data', function (data) {
raw += data;
});
res.on('end', function () {
@diveddie
diveddie / graphql-example
Created May 18, 2020 12:11
This is an example of a graphql query for pulling blogs from Contentful
const result = await graphql(`
query {
allContentfulBlogPost {
edges {
node {
contentful_id
id
tags
title
description {
@diveddie
diveddie / gatsby-createPages-example
Created May 18, 2020 12:15
This is a function to create pages based on blog information.
result.data.allContentfulBlogPost.edges.forEach(({ node }) => {
actions.createPage({
path: `/blogs/${replaceSpacesWithDashes(node.title)}_${
node.contentful_id
}`,
component: require.resolve(
`./src/components/InnerBlog/InnerBlog.tsx`
),
context: { data: node },
})