Skip to content

Instantly share code, notes, and snippets.

Jacob Knaack JacobKnaack

Block or report user

Report or block JacobKnaack

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@JacobKnaack
JacobKnaack / article.js
Created Apr 17, 2019
apollo-blog Article display component
View article.js
import React from 'react'
import { Link } from 'react-router-dom'
import gql from 'graphql-tag'
import { Query } from 'react-apollo'
import { Container, Loader, Label, Image } from 'semantic-ui-react'
import './_article.css'
const GET_ARTICLE_BY_SLUG = gql`
query Article($read_key: String!, $slug: String!) {
object(bucket_slug: "apollo-blog", read_key: $read_key, slug: $slug ) {
@JacobKnaack
JacobKnaack / home.js
Last active Apr 17, 2019
apollo-blog Home View
View home.js
import React from 'react'
import gql from 'graphql-tag'
import { graphql } from 'react-apollo'
import { Link } from 'react-router-dom'
// Component from Semantic UI
import { Container, Image, Card, Label, Loader } from 'semantic-ui-react'
const GET_ARTICLES = gql`
query Articles($read_key: String!) {
@JacobKnaack
JacobKnaack / .env
Created Apr 16, 2019
Apollo-blog environment configuration
View .env
REACT_APP_COSMIC_JS_READ_KEY=your_cosmic_js_read_key
@JacobKnaack
JacobKnaack / App.js
Last active Apr 16, 2019
Apollo-blog root App component
View App.js
import React, { Component } from 'react'
import ApolloClient from 'apollo-boost'
import { ApolloProvider } from 'react-apollo'
import { BrowserRouter, Route } from 'react-router-dom'
import './App.css'
import 'semantic-ui-css/semantic.min.css'
import Home from './views/home'
import Article from './views/article'
@JacobKnaack
JacobKnaack / .env
Last active Apr 17, 2019
gatsby-docs env config
View .env
COSMIC_BUCKET=your-bucket-slug
COSMIC_READ_KEY=your-read-key
COSMIC_WRITE_KEY=your-write-key
@JacobKnaack
JacobKnaack / gatsby-node.js
Last active Feb 15, 2019
Final gatsby-node
View gatsby-node.js
require("dotenv").config();
const path = require('path');
/**
* Implement Gatsby's Node APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/node-apis/
*/
exports.onCreatePage = ({ page, actions }) => {
const { createPage, deletePage } = actions
@JacobKnaack
JacobKnaack / docPage.js
Last active Feb 8, 2019
docPage for gatsby-docs
View docPage.js
import React from 'react'
import showdown from 'showdown'
import PropTypes from 'prop-types'
import Layout from '../components/layout.js'
import SEO from '../components/seo.js'
import { graphql, Link } from 'gatsby'
import hljs from 'highlight.js'
import 'highlight.js/styles/github.css'
const converter = new showdown.Converter({ ghCompatibleHeaderId: true })
@JacobKnaack
JacobKnaack / index.js
Created Jan 24, 2019
Home page for gastby-docs
View index.js
import React from 'react'
import PropTypes from 'prop-types'
import { graphql } from 'gatsby'
import Layout from '../components/layout'
import SEO from '../components/seo'
import Docs from '../components/docs'
const IndexPage = ({ data, pageContext }) => {
return (
@JacobKnaack
JacobKnaack / createDoc.js
Last active Jan 27, 2019
Form for creating a doc object on Cosmic JS
View createDoc.js
import React from 'react'
import PropTypes from 'prop-types'
import Cosmic from 'cosmicjs'
import showdown from 'showdown'
const api = Cosmic()
const converter = new showdown.Converter({ ghCompatibleHeaderId: true })
const initialState = {
open: false,
@JacobKnaack
JacobKnaack / index.js
Last active Feb 8, 2019
docs - initial setup before createDoc
View index.js
import React from 'react'import React from 'react'
import PropTypes from 'prop-types'
import { Link } from 'gatsby'
// formats our slugs to be used in links to our display page
function formatSlug(title) {
return title
.toLowerCase()
.replace(/[^a-zA-Z ]/g, "")
.replace(/\s/g, '-')
You can’t perform that action at this time.