Skip to content

Instantly share code, notes, and snippets.

View johno's full-sized avatar
🖤
Computering

John Otander johno

🖤
Computering
View GitHub Profile

Set up changesets with a release GitHub Action

Changesets is the raddest way to manage monorepos. You can combine changesets with GitHub Actions to automate releases.


Install changesets CLI.

@johno
johno / syntax-highlighting.diff
Created May 7, 2019 17:06
Properly use MDX context components in react-live
diff --git a/src/components/CodeBlock.js b/src/components/CodeBlock.js
index 8b828d6..1751585 100644
--- a/src/components/CodeBlock.js
+++ b/src/components/CodeBlock.js
@@ -2,6 +2,7 @@
import React from 'react'
import Highlight, {defaultProps} from 'prism-react-renderer'
+import {mdx} from '@mdx-js/react'
import {LiveProvider, LiveEditor, LiveError, LivePreview} from 'react-live'
@johno
johno / gatsby-config.js
Created February 23, 2019 13:40
Add gatsby-plugin-page-creator to your Gatsby Theme's config in order to create pages (this will soon be built into themes)
const path = require('path')
module.exports = {
plugins: [
// ...
{
resolve: 'gatsby-plugin-page-creator',
options: {
path: path.join(__dirname, 'src', 'pages')
}
@johno
johno / main.workflow.tf
Created January 4, 2019 00:35
npm and now publishing with GitHub Actions
workflow "npm" {
on = "push"
resolves = ["npm:publish:ci"]
}
action "npm:master" {
uses = "actions/bin/filter@b2bea07"
args = "branch master"
}
@johno
johno / readme.md
Created January 3, 2019 04:05
Programmatic redirects in Gatsby

Programmatic redirects in Gatsby

In the frontmatter of your post you can specify legacy redirects.

---
title: foo
date: 2012-11-10
path: bar
redirects:
@johno
johno / jest.config.js
Last active June 13, 2023 21:20
Mock localStorage with Jest for React testing
module.exports = {
testPathIgnorePatterns: ['<rootDir>/.next/', '<rootDir>/node_modules/'],
setupFiles: ['./test-setup.js']
}
@johno
johno / App.js
Created April 16, 2018 21:15
Dynamic MDX rendering
import React from 'react'
import Markdown from './Markdown'
const components = {
h1: props => <h1 style={{ color: 'tomato' }} {...props} />
}
const scope = {
name: 'world!',
Box: props => <div style={{border: 'thin solid tomato'}} {...props} />
@johno
johno / App.js
Created April 16, 2018 21:15
Dynamic MDX rendering
import React from 'react'
import Markdown from './Markdown'
const components = {
h1: props => <h1 style={{ color: 'tomato' }} {...props} />
}
const scope = {
name: 'world!',
Box: props => <div style={{border: 'thin solid tomato'}} {...props} />
@johno
johno / Kit.jsx
Last active March 6, 2018 17:29
c8r/kit - A storybook alternative with a pure JSX/MDX API that interfaces with existing projects
import React from 'react'
import {
Provider,
Library,
Example,
Documentation,
Knobs,
contextTypes
} from '@compositor/kit'