@@ -70,6 +70,12 @@ const { data: readmeData } = useLazyFetch<ReadmeResponse>(
7070 { default : () => ({ html: ' ' , playgroundLinks: [], toc: [] }) },
7171)
7272
73+ // copy README file
74+ const { copied : copiedReadme, copy : copyReadme } = useClipboard ({
75+ source: readmeData .value ?.html ?? ' ' ,
76+ copiedDuring: 2000 ,
77+ })
78+
7379// Track active TOC item based on scroll position
7480const tocItems = computed (() => readmeData .value ?.toc ?? [])
7581const { activeId : activeTocId, scrollToHeading } = useActiveTocItem (tocItems )
@@ -1130,12 +1136,39 @@ onKeyStroke(
11301136 </a >
11311137 </h2 >
11321138 <ClientOnly >
1133- <ReadmeTocDropdown
1134- v-if =" readmeData?.toc && readmeData.toc.length > 1"
1135- :toc =" readmeData.toc"
1136- :active-id =" activeTocId"
1137- :scroll-to-heading =" scrollToHeading"
1138- />
1139+ <div class =" flex items-center gap-2" >
1140+ <TooltipApp
1141+ v-if =" readmeData?.html"
1142+ :text =" copiedReadme ? 'Copied!' : 'Copy README as markdown'"
1143+ position =" bottom"
1144+ >
1145+ <button
1146+ type =" button"
1147+ @click =" copyReadme()"
1148+ :disabled =" !readmeData?.html"
1149+ class =" inline-flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-mono rounded border transition-all duration-150 disabled:opacity-50 disabled:cursor-not-allowed"
1150+ :class ="
1151+ copiedReadme
1152+ ? 'text-accent bg-accent/10 border-accent'
1153+ : 'text-fg-subtle bg-bg border-border-subtle hover:border-border hover:text-fg'
1154+ "
1155+ :aria-label =" copiedReadme ? 'Copied!' : 'Copy README'"
1156+ >
1157+ <span
1158+ :class =" copiedReadme ? 'i-carbon:checkmark' : 'i-simple-icons:markdown'"
1159+ class =" w-3.5 h-3.5"
1160+ aria-hidden =" true"
1161+ />
1162+ {{ copiedReadme ? $t('common.copied') : 'Copy' }}
1163+ </button >
1164+ </TooltipApp >
1165+ <ReadmeTocDropdown
1166+ v-if =" readmeData?.toc && readmeData.toc.length > 1"
1167+ :toc =" readmeData.toc"
1168+ :active-id =" activeTocId"
1169+ :scroll-to-heading =" scrollToHeading"
1170+ />
1171+ </div >
11391172 </ClientOnly >
11401173 </div >
11411174
0 commit comments