Skip to content

Commit 3e61c6a

Browse files
IdrisGitghostdevv
authored andcommitted
feat: add copy readme to markdown button
1 parent bd4b408 commit 3e61c6a

5 files changed

Lines changed: 14 additions & 6 deletions

File tree

app/pages/package/[[org]]/[name].vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,12 +1152,11 @@ onKeyStroke(
11521152
<button
11531153
type="button"
11541154
@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-
"
1155+
v-if="readmeData?.md"
1156+
class="flex items-center h-8 gap-1.5 px-2 py-2 font-mono text-xs bg-bg-subtle border border-border-subtle border-solid rounded-md transition-colors duration-150 hover:(text-fg border-border-hover) active:scale-95 focus:border-border-hover hover:text-fg"
1157+
:class="copiedReadme ? 'text-fg' : 'text-fg-muted'"
11591158
:aria-label="
1160-
copiedReadme ? $t('common.copied') : $t('package.readme.copy_as_markdown')
1159+
copiedReadme ? $t('common.copied') : $t('package.readme.copy_markdown')
11611160
"
11621161
>
11631162
<span
@@ -1174,6 +1173,12 @@ onKeyStroke(
11741173
:active-id="activeTocId"
11751174
:scroll-to-heading="scrollToHeading"
11761175
/>
1176+
<ReadmeTocDropdown
1177+
v-if="readmeData?.toc && readmeData.toc.length > 1"
1178+
:toc="readmeData.toc"
1179+
:active-id="activeTocId"
1180+
:scroll-to-heading="scrollToHeading"
1181+
/>
11771182
</div>
11781183
</ClientOnly>
11791184
</div>

i18n/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@
215215
"no_readme": "No README available.",
216216
"view_on_github": "View on GitHub",
217217
"toc_title": "Outline",
218+
"copy_markdown": "Copy markdown",
218219
"callout": {
219220
"note": "Note",
220221
"tip": "Tip",

lunaria/files/en-GB.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@
215215
"no_readme": "No README available.",
216216
"view_on_github": "View on GitHub",
217217
"toc_title": "Outline",
218+
"copy_markdown": "Copy markdown",
218219
"callout": {
219220
"note": "Note",
220221
"tip": "Tip",

lunaria/files/en-US.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@
215215
"no_readme": "No README available.",
216216
"view_on_github": "View on GitHub",
217217
"toc_title": "Outline",
218+
"copy_markdown": "Copy markdown",
218219
"callout": {
219220
"note": "Note",
220221
"tip": "Tip",

server/api/registry/readme/[...pkg].get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export default defineCachedEventHandler(
107107
}
108108

109109
if (!readmeContent || readmeContent === NPM_MISSING_README_SENTINEL) {
110-
return { html: '', playgroundLinks: [], toc: [] }
110+
return { html: '', markdown: '', playgroundLinks: [], toc: [] }
111111
}
112112

113113
// Parse repository info for resolving relative URLs to GitHub

0 commit comments

Comments
 (0)