|
| 1 | +<script setup lang="ts"> |
| 2 | +const route = useRoute() |
| 3 | +const toast = useToast() |
| 4 | +const { copy, copied } = useClipboard() |
| 5 | +const site = useSiteConfig() |
| 6 | +
|
| 7 | +const mdPath = computed(() => `${site.url}/raw${route.path}.md`) |
| 8 | +
|
| 9 | +const items = [ |
| 10 | + { |
| 11 | + label: 'Copy Markdown link', |
| 12 | + icon: 'i-lucide-link', |
| 13 | + onSelect() { |
| 14 | + copy(mdPath.value) |
| 15 | + toast.add({ |
| 16 | + title: 'Copied to clipboard', |
| 17 | + icon: 'i-lucide-check-circle' |
| 18 | + }) |
| 19 | + } |
| 20 | + }, |
| 21 | + { |
| 22 | + label: 'View as Markdown', |
| 23 | + icon: 'i-simple-icons:markdown', |
| 24 | + target: '_blank', |
| 25 | + to: `/raw${route.path}.md` |
| 26 | + }, |
| 27 | + { |
| 28 | + label: 'Open in ChatGPT', |
| 29 | + icon: 'i-simple-icons:openai', |
| 30 | + target: '_blank', |
| 31 | + to: `https://chatgpt.com/?hints=search&q=${encodeURIComponent(`Read ${mdPath.value} so I can ask questions about it.`)}` |
| 32 | + }, |
| 33 | + { |
| 34 | + label: 'Open in Claude', |
| 35 | + icon: 'i-simple-icons:anthropic', |
| 36 | + target: '_blank', |
| 37 | + to: `https://claude.ai/new?q=${encodeURIComponent(`Read ${mdPath.value} so I can ask questions about it.`)}` |
| 38 | + } |
| 39 | +] |
| 40 | +
|
| 41 | +async function copyPage() { |
| 42 | + copy(await $fetch<string>(`/raw${route.path}.md`)) |
| 43 | +} |
| 44 | +</script> |
| 45 | + |
| 46 | +<template> |
| 47 | + <UButtonGroup> |
| 48 | + <UButton |
| 49 | + label="Copy page" |
| 50 | + :icon="copied ? 'i-lucide-copy-check' : 'i-lucide-copy'" |
| 51 | + color="neutral" |
| 52 | + variant="outline" |
| 53 | + :ui="{ |
| 54 | + leadingIcon: [copied ? 'text-primary' : 'text-neutral', 'size-3.5'] |
| 55 | + }" |
| 56 | + @click="copyPage" |
| 57 | + /> |
| 58 | + <UDropdownMenu |
| 59 | + :items="items" |
| 60 | + :content="{ |
| 61 | + align: 'end', |
| 62 | + side: 'bottom', |
| 63 | + sideOffset: 8 |
| 64 | + }" |
| 65 | + :ui="{ |
| 66 | + content: 'w-48' |
| 67 | + }" |
| 68 | + > |
| 69 | + <UButton |
| 70 | + icon="i-lucide-chevron-down" |
| 71 | + size="sm" |
| 72 | + color="neutral" |
| 73 | + variant="outline" |
| 74 | + /> |
| 75 | + </UDropdownMenu> |
| 76 | + </UButtonGroup> |
| 77 | +</template> |
0 commit comments