Skip to content

Instantly share code, notes, and snippets.

@garybernhardt
Created March 17, 2020 21:21
Show Gist options
  • Save garybernhardt/910b06e74c94245c8ff3699326c48a02 to your computer and use it in GitHub Desktop.
Save garybernhardt/910b06e74c94245c8ff3699326c48a02 to your computer and use it in GitHub Desktop.
import React, { useEffect } from "react"
import { META_DESCRIPTION } from "../../util"
export const Page: React.FC<{
title?: string
metaDescription?: string
}> = props => {
useEffect(() => {
document.title = props.title ?? "Execute Program"
}, [props.title])
useEffect(() => {
const node = document.querySelector('meta[name="description"]')
if (!node) {
throw new Error("BUG: couldn't find meta description node")
}
node.setAttribute("content", props.metaDescription ?? META_DESCRIPTION)
}, [props.metaDescription])
return <>{props.children}</>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment