MCPcopy Create free account
hub / github.com/arktypeio/arktype / useCopyMarkdown

Function useCopyMarkdown

ark/docs/components/shell/CopyPage.tsx:32–49  ·  view source on GitHub ↗
(markdownUrl: string)

Source from the content-addressed store, hash-verified

30
31/** copies the page's Markdown, reporting the result for a moment after */
32export const useCopyMarkdown = (markdownUrl: string) => {
33 const [result, setResult] = useState<CopyResult>()
34 const timeout = useRef<ReturnType<typeof setTimeout>>(undefined)
35
36 useEffect(() => () => clearTimeout(timeout.current), [])
37
38 const copy = async () => {
39 const next = await writeMarkdown(markdownUrl).then(
40 () => "copied" as const,
41 () => "failed" as const
42 )
43 setResult(next)
44 clearTimeout(timeout.current)
45 timeout.current = setTimeout(() => setResult(undefined), resultFor)
46 }
47
48 return { result, copy }
49}
50
51/** every state of "Copy page" in one grid cell, so the button never resizes */
52export const CopyFace = ({ result }: { result: CopyResult }) => (

Callers 2

TocFunction · 0.90
CopyPageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected