Skip to content

Instantly share code, notes, and snippets.

View ghankerson's full-sized avatar

Geoff Hankerson ghankerson

  • American Public Media
View GitHub Profile
{
collection(slug: "homepage", contentAreaSlug: "mprnews") {
title
body
canonicalSlug
results {
items {
title
canonicalSlug
description
{
story(slug: "2025/09/12/theme-and-variations-with-tom-crann", contentAreaSlug: "yourclassical") {
title
canonicalSlug
body
primaryVisuals {
video {
caption
background
url
"use client";
import { useState } from "react";
import { useForm } from "react-hook-form";
import { Prisma } from "@prisma/client";
import Song from './Song';
interface PollProps {
poll: Prisma.pollsSelect;
}
import React, { ReactNode } from 'react';
import { Notifier } from '@airbrake/browser';
interface Props {
fallbackUI?: ReactNode;
}
interface StateProps {
hasError: boolean;
}
@ghankerson
ghankerson / viafoura.jsx
Last active December 13, 2021 20:06
Viafoura/React/Next JS/Single page app implementation
import Head from 'next/head';
import { useRouter } from 'next/router';
import loadScript from '../../utils/loadScript';
const Content = ({
useViafoura,
}) => {
const router = useRouter();
const source = '//cdn.viafoura.net/vf-v2.js';
const [viaFouraReady, setViafouraReady] = useState(false);
@ghankerson
ghankerson / loadScript.js
Last active December 13, 2021 19:19
Abbreviated NextJS/React Viafoura Implementation loadScript
const loadScript = function(id, src, callback) {
const existingScript = document.getElementById(id);
if (!existingScript) {
const script = document.createElement('script');
script.src = src;
script.id = id;
document.body.appendChild(script);
script.onload = () => {
@ghankerson
ghankerson / audio.html
Created June 2, 2020 21:11
HTML Audio tag for live stream
<audio controls>
<source src="https://news-utility.stream.publicradio.org/news-utility.aac" type="audio/aac">
<source src="https://news-utility.stream.publicradio.org/news-utility.mp3" type="audio/mpeg">
</audio>
import fetch from 'cross-fetch';
import { ApolloClient } from 'apollo-client';
import { createHttpLink } from 'apollo-link-http';
import { InMemoryCache } from 'apollo-cache-inmemory';
import FragmentMatcher from './FragmentMatcher';
const cache = new InMemoryCache({ fragmentMatcher: FragmentMatcher }).restore(window.__APOLLO_STATE__);
export function client(graphqlEnv) {
return new ApolloClient({
import React from 'react';
import ReactDOM from 'react-dom/server';
import { ApolloProvider, renderToStringWithData } from 'react-apollo';
import { HelmetProvider } from 'react-helmet-async';
import { ServerLocation } from 'apm-titan';
// import { client } from '../shared/graphql/graphqlClient';
import App from '../shared/App';
import fs from 'fs';
import os from 'os';
import {
import App from '../shared/App';
import React from 'react';
import { hydrate } from 'react-dom';
import { ApolloProvider } from 'react-apollo';
import { HelmetProvider } from 'react-helmet-async';
import { client } from '../shared/graphql/graphqlClient';
import '@babel/polyfill';
const graphqlEnv = window.location.href.match(/local|dev/) ? '-dev' : '';