Pass markdown and config to function
micromarkAbbr(markdown, config)
import React, { useEffect, useState } from 'react'; | |
const Page = () => { | |
const [response, setResponse] = useState(false); | |
useEffect(() => { | |
const getData = async () => { | |
const response = await fetch( | |
'https://api.oceandrivers.com/api/ODWeather' | |
); |
import { useEffect, useState } from 'react' | |
const useLocalStorage = (key, initialValue) => { | |
const [storedValue, setStoredValue] = useState(initialValue) | |
const setValue = (value) => { | |
try { | |
const valueToStore = | |
value instanceof Function ? value(storedValue) : value | |
setStoredValue(valueToStore) | |
window.localStorage.setItem(key, JSON.stringify(valueToStore)) |
import React from 'react'; | |
import { useStaticQuery, graphql } from 'gatsby'; | |
import { GatsbyImage, getImage } from 'gatsby-plugin-image'; | |
const Test = () => { | |
const { | |
file: { | |
childImageSharp: { gatsbyImageData } | |
} | |
} = useStaticQuery(graphql` |
export const onRouteUpdate = ({ location }) => { | |
const jumplink = document.getElementById(location.hash) | |
if (jumplink) { | |
window.scrollTo({ | |
top: jumplink.offsetTop, | |
}) | |
} | |
return true | |
} |
import React, { Fragment } from 'react'; | |
export const wrapPageElement = ({ element, props }) => { | |
const { | |
location: { pathname }, | |
} = props | |
return ( | |
<Fragment> | |
<header className={`${pathname === '/' ? 'some-class' : 'some-other-class'} `}> |
import { useState, useEffect } from 'react' | |
const QUERY_STRING = '(prefers-reduced-motion: no-preference)' | |
const EVENT = 'change' | |
const usePrefersReducedMotion = () => { | |
const [prefersReducedMotion, setPrefersReducedMotion] = useState(true) | |
useEffect(() => { | |
const query = window.matchMedia(QUERY_STRING) |
{ | |
"contentTypes": [ | |
{ | |
"sys": { | |
"space": { | |
"sys": { | |
"type": "Link", | |
"linkType": "Space", | |
"id": "816y14uaxxqf" | |
} |
const sampleData = [ | |
{ | |
date: 'Sun Jan 02 2022 00:00:00 GMT+0000 (Greenwich Mean Time)', | |
year: 2022, | |
additions: 9932, | |
deletions: -7938 | |
}, | |
{ | |
date: 'Sun Jan 09 2022 00:00:00 GMT+0000 (Greenwich Mean Time)', | |
year: 2022, |
const sampleData = [ | |
{ | |
total: 84, | |
date: 'Sun Oct 10 2021 01:00:00 GMT+0100 (British Summer Time)' | |
}, | |
{ | |
total: 91, | |
date: 'Sun Oct 17 2021 01:00:00 GMT+0100 (British Summer Time)' | |
}, | |
{ |