|
| 1 | +export default function CopyPage({ file }: { file: string | undefined }) { |
| 2 | + if (!file || file.includes("[")) return null; |
| 3 | + |
| 4 | + const markdownUrl = `https://docs.deno.com${file}`; |
| 5 | + const claudeUrl = `https://claude.ai/new?q=${ |
| 6 | + encodeURIComponent( |
| 7 | + `Read this page from the Deno docs: ${markdownUrl} and answer questions about the content.`, |
| 8 | + ) |
| 9 | + }`; |
| 10 | + |
| 11 | + return ( |
| 12 | + <details class="copy-page-dropdown mb-4"> |
| 13 | + <summary class="btn list-none [&::-webkit-details-marker]:hidden flex items-center gap-2 cursor-pointer select-none"> |
| 14 | + <svg |
| 15 | + xmlns="http://www.w3.org/2000/svg" |
| 16 | + aria-hidden="true" |
| 17 | + fill="currentColor" |
| 18 | + width="14" |
| 19 | + height="14" |
| 20 | + viewBox="0 0 16 16" |
| 21 | + > |
| 22 | + <path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z" /> |
| 23 | + <path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z" /> |
| 24 | + </svg> |
| 25 | + Copy page |
| 26 | + <svg |
| 27 | + class="copy-page-chevron ml-1 transition-transform duration-200" |
| 28 | + xmlns="http://www.w3.org/2000/svg" |
| 29 | + aria-hidden="true" |
| 30 | + fill="currentColor" |
| 31 | + width="12" |
| 32 | + height="12" |
| 33 | + viewBox="0 0 16 16" |
| 34 | + > |
| 35 | + <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z" /> |
| 36 | + </svg> |
| 37 | + </summary> |
| 38 | + |
| 39 | + <div class="mt-2 border border-foreground-tertiary rounded-md overflow-hidden bg-white dark:bg-gray-900"> |
| 40 | + <button |
| 41 | + class="copy-page-link-btn flex items-start gap-3 w-full px-4 py-3 text-left hover:bg-background-secondary dark:hover:bg-gray-800 transition-colors" |
| 42 | + > |
| 43 | + <svg |
| 44 | + xmlns="http://www.w3.org/2000/svg" |
| 45 | + aria-hidden="true" |
| 46 | + fill="currentColor" |
| 47 | + width="16" |
| 48 | + height="16" |
| 49 | + viewBox="0 0 16 16" |
| 50 | + class="mt-0.5 shrink-0" |
| 51 | + > |
| 52 | + <path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 2 2 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a2.002 2.002 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 2 2 0 0 0-2.83 0l-2.5 2.5a2.002 2.002 0 0 0 0 2.83Z" /> |
| 53 | + </svg> |
| 54 | + <span> |
| 55 | + <span class="copy-page-link-label block text-sm font-medium"> |
| 56 | + Copy page link |
| 57 | + </span> |
| 58 | + <span class="block text-xs text-foreground-secondary mt-0.5"> |
| 59 | + Copy the current page URL to clipboard |
| 60 | + </span> |
| 61 | + </span> |
| 62 | + </button> |
| 63 | + |
| 64 | + <a |
| 65 | + href={file} |
| 66 | + target="_blank" |
| 67 | + class="flex items-start gap-3 px-4 py-3 border-t border-foreground-tertiary hover:bg-background-secondary dark:hover:bg-gray-800 transition-colors" |
| 68 | + > |
| 69 | + <svg |
| 70 | + xmlns="http://www.w3.org/2000/svg" |
| 71 | + aria-hidden="true" |
| 72 | + fill="currentColor" |
| 73 | + width="16" |
| 74 | + height="16" |
| 75 | + viewBox="0 0 16 16" |
| 76 | + class="mt-0.5 shrink-0" |
| 77 | + > |
| 78 | + <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z" /> |
| 79 | + </svg> |
| 80 | + <span> |
| 81 | + <span class="block text-sm font-medium">View Page as Markdown</span> |
| 82 | + <span class="block text-xs text-foreground-secondary mt-0.5"> |
| 83 | + Open the Markdown file in a new tab |
| 84 | + </span> |
| 85 | + </span> |
| 86 | + </a> |
| 87 | + |
| 88 | + <a |
| 89 | + href={claudeUrl} |
| 90 | + target="_blank" |
| 91 | + class="flex items-start gap-3 px-4 py-3 border-t border-foreground-tertiary hover:bg-background-secondary dark:hover:bg-gray-800 transition-colors" |
| 92 | + > |
| 93 | + <svg |
| 94 | + xmlns="http://www.w3.org/2000/svg" |
| 95 | + aria-hidden="true" |
| 96 | + fill="currentColor" |
| 97 | + width="16" |
| 98 | + height="16" |
| 99 | + viewBox="0 0 24 24" |
| 100 | + class="mt-0.5 shrink-0" |
| 101 | + > |
| 102 | + <path d="M12 0C12 0 10.5 10.5 0 12C10.5 12 12 24 12 24C12 24 13.5 13.5 24 12C13.5 12 12 0 12 0Z" /> |
| 103 | + </svg> |
| 104 | + <span> |
| 105 | + <span class="block text-sm font-medium">Open in Claude</span> |
| 106 | + <span class="block text-xs text-foreground-secondary mt-0.5"> |
| 107 | + Ask Claude about this page |
| 108 | + </span> |
| 109 | + </span> |
| 110 | + </a> |
| 111 | + </div> |
| 112 | + </details> |
| 113 | + ); |
| 114 | +} |
0 commit comments