Created
March 17, 2020 21:21
-
-
Save garybernhardt/910b06e74c94245c8ff3699326c48a02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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