@@ -62,9 +62,15 @@ const { data: readmeData } = useLazyFetch<ReadmeResponse>(
6262 const version = requestedVersion .value
6363 return version ? ` ${base }/v/${version } ` : base
6464 },
65- { default : () => ({ html: ' ' , playgroundLinks: [], toc: [] }) },
65+ { default : () => ({ html: ' ' , md: ' ' , playgroundLinks: [], toc: [] }) },
6666)
6767
68+ // copy README file as Markdown
69+ const { copied : copiedReadme, copy : copyReadme } = useClipboard ({
70+ source : () => readmeData .value ?.md ?? ' ' ,
71+ copiedDuring: 2000 ,
72+ })
73+
6874// Track active TOC item based on scroll position
6975const tocItems = computed (() => readmeData .value ?.toc ?? [])
7076const { activeId : activeTocId, scrollToHeading } = useActiveTocItem (tocItems )
@@ -1136,12 +1142,39 @@ onKeyStroke(
11361142 </a >
11371143 </h2 >
11381144 <ClientOnly >
1139- <ReadmeTocDropdown
1140- v-if =" readmeData?.toc && readmeData.toc.length > 1"
1141- :toc =" readmeData.toc"
1142- :active-id =" activeTocId"
1143- :scroll-to-heading =" scrollToHeading"
1144- />
1145+ <div class =" flex items-center gap-2" >
1146+ <!-- Copy readme as Markdown button -->
1147+ <TooltipApp
1148+ v-if =" readmeData?.md"
1149+ :text =" $t('package.readme.copy_as_markdown')"
1150+ position =" bottom"
1151+ >
1152+ <button
1153+ type =" button"
1154+ @click =" copyReadme()"
1155+ class =" px-2 py-1.5 font-mono text-xs rounded transition-colors duration-150 inline-flex items-center gap-1.5"
1156+ :class ="
1157+ copiedReadme ? 'text-accent bg-accent/10' : 'text-fg-subtle bg-bg hover:text-fg'
1158+ "
1159+ :aria-label ="
1160+ copiedReadme ? $t('common.copied') : $t('package.readme.copy_as_markdown')
1161+ "
1162+ >
1163+ <span
1164+ :class =" copiedReadme ? 'i-carbon:checkmark' : 'i-simple-icons:markdown'"
1165+ class =" size-3"
1166+ aria-hidden =" true"
1167+ />
1168+ {{ copiedReadme ? $t('common.copied') : $t('common.copy') }}
1169+ </button >
1170+ </TooltipApp >
1171+ <ReadmeTocDropdown
1172+ v-if =" readmeData?.toc && readmeData.toc.length > 1"
1173+ :toc =" readmeData.toc"
1174+ :active-id =" activeTocId"
1175+ :scroll-to-heading =" scrollToHeading"
1176+ />
1177+ </div >
11451178 </ClientOnly >
11461179 </div >
11471180
0 commit comments