|
| 1 | +<script setup lang="ts"> |
| 2 | +import { useClipboard } from '@vueuse/core' |
| 3 | +
|
| 4 | +const route = useRoute() |
| 5 | +const toast = useToast() |
| 6 | +const { copy, copied } = useClipboard() |
| 7 | +const site = useSiteConfig() |
| 8 | +const isCopying = ref(false) |
| 9 | +
|
| 10 | +const mdPath = computed(() => `${site.url}/raw${route.path}.md`) |
| 11 | +
|
| 12 | +const items = [ |
| 13 | + [ |
| 14 | + { |
| 15 | + label: 'Copy Markdown link', |
| 16 | + icon: 'i-lucide-link', |
| 17 | + onSelect() { |
| 18 | + copy(mdPath.value) |
| 19 | + toast.add({ |
| 20 | + title: 'Copied to clipboard', |
| 21 | + icon: 'i-lucide-check-circle' |
| 22 | + }) |
| 23 | + } |
| 24 | + }, |
| 25 | + { |
| 26 | + label: 'View as Markdown', |
| 27 | + icon: 'i-simple-icons:markdown', |
| 28 | + target: '_blank', |
| 29 | + to: `/raw${route.path}.md` |
| 30 | + }, |
| 31 | + { |
| 32 | + label: 'Open in ChatGPT', |
| 33 | + icon: 'i-simple-icons:openai', |
| 34 | + target: '_blank', |
| 35 | + to: `https://chatgpt.com/?hints=search&q=${encodeURIComponent(`Read ${mdPath.value} so I can ask questions about it.`)}` |
| 36 | + }, |
| 37 | + { |
| 38 | + label: 'Open in Claude', |
| 39 | + icon: 'i-simple-icons:anthropic', |
| 40 | + target: '_blank', |
| 41 | + to: `https://claude.ai/new?q=${encodeURIComponent(`Read ${mdPath.value} so I can ask questions about it.`)}` |
| 42 | + } |
| 43 | + ], |
| 44 | + [ |
| 45 | + { |
| 46 | + label: 'Copy MCP Server URL', |
| 47 | + icon: 'i-lucide-link', |
| 48 | + onSelect() { |
| 49 | + copy(`https://hub.nuxt.com/mcp`) |
| 50 | + toast.add({ |
| 51 | + title: 'Copied to clipboard', |
| 52 | + icon: 'i-lucide-check-circle' |
| 53 | + }) |
| 54 | + } |
| 55 | + }, |
| 56 | + { |
| 57 | + label: 'Add MCP Server', |
| 58 | + icon: 'i-simple-icons:cursor', |
| 59 | + target: '_blank', |
| 60 | + to: `/mcp/deeplink` |
| 61 | + } |
| 62 | + ] |
| 63 | +] |
| 64 | +
|
| 65 | +async function copyPage() { |
| 66 | + isCopying.value = true |
| 67 | + copy(await $fetch<string>(`/raw${route.path}.md`)) |
| 68 | + isCopying.value = false |
| 69 | +} |
| 70 | +</script> |
| 71 | + |
| 72 | +<template> |
| 73 | + <UFieldGroup> |
| 74 | + <UButton |
| 75 | + label="Copy page" |
| 76 | + :icon="copied ? 'i-lucide-clipboard-check' : 'i-lucide-clipboard'" |
| 77 | + color="neutral" |
| 78 | + variant="soft" |
| 79 | + size="sm" |
| 80 | + :loading="isCopying" |
| 81 | + :ui="{ |
| 82 | + leadingIcon: 'size-3.5' |
| 83 | + }" |
| 84 | + @click="copyPage" |
| 85 | + /> |
| 86 | + <UDropdownMenu |
| 87 | + :items="items" |
| 88 | + :content="{ |
| 89 | + align: 'end', |
| 90 | + side: 'bottom', |
| 91 | + sideOffset: 8 |
| 92 | + }" |
| 93 | + :ui="{ |
| 94 | + content: 'w-48' |
| 95 | + }" |
| 96 | + > |
| 97 | + <UButton |
| 98 | + icon="i-lucide-chevron-down" |
| 99 | + size="sm" |
| 100 | + color="neutral" |
| 101 | + variant="soft" |
| 102 | + class="border-l border-muted" |
| 103 | + aria-label="Open copy options" |
| 104 | + :ui="{ |
| 105 | + leadingIcon: 'size-3.5' |
| 106 | + }" |
| 107 | + /> |
| 108 | + </UDropdownMenu> |
| 109 | + </UFieldGroup> |
| 110 | +</template> |
0 commit comments