diff --git a/src/components/PageHeading.tsx b/src/components/PageHeading.tsx index ba4b413a09b..1a399b63eca 100644 --- a/src/components/PageHeading.tsx +++ b/src/components/PageHeading.tsx @@ -19,7 +19,9 @@ import {useRouter} from 'next/router'; import {IconCanary} from './Icon/IconCanary'; import {IconExperimental} from './Icon/IconExperimental'; import {IconCopy} from './Icon/IconCopy'; -import {Button} from './Button'; +import {IconChevron} from './Icon/IconChevron'; +import {Menu} from '@headlessui/react'; +import {IconNewPage} from './Icon/IconNewPage'; interface PageHeadingProps { title: string; @@ -35,6 +37,13 @@ function CopyAsMarkdownButton() { const {asPath} = useRouter(); const [copied, setCopied] = useState(false); + const cleanPath = asPath.split(/[?#]/)[0]; + const mdPath = cleanPath + '.md'; + const fullMdUrl = + typeof window !== 'undefined' + ? `${window.location.origin}${mdPath}` + : mdPath; + useEffect(() => { if (!copied) return; const timer = setTimeout(() => setCopied(false), 2000); @@ -42,8 +51,7 @@ function CopyAsMarkdownButton() { }, [copied]); async function fetchPageBlob() { - const cleanPath = asPath.split(/[?#]/)[0]; - const res = await fetch(cleanPath + '.md'); + const res = await fetch(mdPath); if (!res.ok) throw new Error('Failed to fetch'); const text = await res.text(); return new Blob([text], {type: 'text/plain'}); @@ -62,17 +70,89 @@ function CopyAsMarkdownButton() { } return ( - +
+ + +
); }