diff --git a/site/src/components/DocWrapper.js b/site/src/components/DocWrapper.js index 4f65084bb..6f34d84bb 100644 --- a/site/src/components/DocWrapper.js +++ b/site/src/components/DocWrapper.js @@ -14,6 +14,7 @@ import { getDocMap, docList } from '../utils/misc' import DocMetadata from './DocMetadata' import Search from './Search' +import EthicalAd from './EthicalAd' let space = constants.space const scaleAnimation = keyframes` @@ -181,6 +182,7 @@ export default ({ })} > + {docList.map(item => { return ( diff --git a/site/src/components/EthicalAd.js b/site/src/components/EthicalAd.js new file mode 100644 index 000000000..2ded3f3c9 --- /dev/null +++ b/site/src/components/EthicalAd.js @@ -0,0 +1,68 @@ +import React from 'react' + +function removeNode(node) { + node.parentNode.removeChild(node) +} + +const useMediaQuery = mediaQuery => { + const mediaObj = React.useMemo(() => window.matchMedia(mediaQuery), [ + mediaQuery + ]) + const [matches, setMatches] = React.useState(mediaObj.matches) + React.useLayoutEffect( + () => { + const updater = () => setMatches(mediaObj.matches) + mediaObj.addListener(updater) + return () => mediaObj.removeListener(updater) + }, + [mediaObj] + ) + return matches +} + +export default function EthicalAd({ mediaQuery = '', ...props }) { + if (typeof window === 'undefined') { + return ( + <> +
+