MCPcopy
hub / github.com/intentui/intentui / OpenIn

Function OpenIn

src/components/open-in.tsx:34–180  ·  view source on GitHub ↗
({
  tree,
  url,
  page,
  toc,
}: {
  tree: PageTreeRoot
  url: string
  page: string
  toc: TableOfContents
})

Source from the content-addressed store, hash-verified

32}
33
34export function OpenIn({
35 tree,
36 url,
37 page,
38 toc,
39}: {
40 tree: PageTreeRoot
41 url: string
42 page: string
43 toc: TableOfContents
44}) {
45 const fullUrl = `${app.url}${url}`
46 const [pending, setPending] = useState(false)
47 const llmUrl = `${fullUrl}.md`
48 const { copied, copy } = useClipboard()
49
50 async function getMarkdown() {
51 setPending(true)
52
53 try {
54 const res = await fetch(llmUrl, { method: 'GET' })
55 const text = res.ok ? await res.text() : page
56 await copy(text)
57 window.aurelie?.track?.(`copy page: ${fullUrl}`, { url: fullUrl })
58 } finally {
59 setPending(false)
60 }
61 }
62
63 return (
64 <div className="not-prose ml-auto flex items-center justify-between gap-x-1.5 md:border-transparent">
65 <ButtonGroup className="hidden sm:flex">
66 <Button
67 className="h-10 rounded-sm sm:h-auto dark:bg-secondary/50 dark:hover:bg-secondary"
68 intent="outline"
69 size="sm"
70 onPress={() => void getMarkdown()}
71 isPending={pending}
72 >
73 {pending ? <Loader /> : copied ? <CheckIcon /> : <DuplicateIcon />}
74 Copy page
75 </Button>
76 <Menu>
77 <Button
78 className="h-10 rounded-sm pressed:bg-secondary pressed:*:text-fg sm:h-auto dark:bg-secondary/50 dark:hover:bg-secondary"
79 intent="outline"
80 size="sm"
81 >
82 <ChevronDownIcon className="rotate-180 sm:rotate-0" />
83 </Button>
84 <MenuContent className="min-w-40" placement="bottom end">
85 <MenuItem href={`${url}.md`} target="_blank" rel="noopener noreferrer">
86 <svg strokeLinejoin="round" viewBox="0 0 22 16">
87 <path
88 fillRule="evenodd"
89 clipRule="evenodd"
90 d="M19.5 2.25H2.5C1.80964 2.25 1.25 2.80964 1.25 3.5V12.5C1.25 13.1904 1.80964 13.75 2.5 13.75H19.5C20.1904 13.75 20.75 13.1904 20.75 12.5V3.5C20.75 2.80964 20.1904 2.25 19.5 2.25ZM2.5 1C1.11929 1 0 2.11929 0 3.5V12.5C0 13.8807 1.11929 15 2.5 15H19.5C20.8807 15 22 13.8807 22 12.5V3.5C22 2.11929 20.8807 1 19.5 1H2.5ZM3 4.5H4H4.25H4.6899L4.98715 4.82428L7 7.02011L9.01285 4.82428L9.3101 4.5H9.75H10H11V5.5V11.5H9V7.79807L7.73715 9.17572L7 9.97989L6.26285 9.17572L5 7.79807V11.5H3V5.5V4.5ZM15 8V4.5H17V8H19.5L17 10.5L16 11.5L15 10.5L12.5 8H15Z"
91 fill="currentColor"

Callers

nothing calls this directly

Calls 4

useClipboardFunction · 0.90
getMarkdownFunction · 0.85
getPromptUrlFunction · 0.85
getPerplexityUrlFunction · 0.85

Tested by

no test coverage detected