Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions app/composables/useClipboardAsync.ts

This file was deleted.

25 changes: 17 additions & 8 deletions app/pages/package/[[org]]/[name].vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,20 @@ const {
)

//copy README file as Markdown
const { copied: copiedReadme, copy: copyReadme } = useClipboardAsync(
async () => {
const {
copied: copiedReadme,
copy,
copyPending: copyReadmePending,
} = useClipboard({
copiedDuring: 2000,
})

function copyReadme() {
copy(async () => {
await fetchReadmeMarkdown()
return readmeMarkdownData.value?.markdown ?? ''
},
{
copiedDuring: 2000,
},
)
})
}
Comment on lines +119 to +124
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Don't copy an empty README on fetch failure.

The helper currently falls back to '' when the markdown ref is empty, so a failed fetch can still look like a successful copy. Return early or surface an error instead of treating missing markdown as valid content.

🛠 Suggested fix
 async function copyReadme() {
   copy(async () => {
     await fetchReadmeMarkdown()
-    return readmeMarkdownData.value?.markdown ?? ''
+    const markdown = readmeMarkdownData.value?.markdown
+    if (!markdown) throw new Error('README Markdown is unavailable')
+    return markdown
   })
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/pages/package/`[[org]]/[name].vue around lines 119 - 124, The copyReadme
helper currently calls copy with an empty string when fetchReadmeMarkdown fails;
change copyReadme so it awaits fetchReadmeMarkdown, checks
readmeMarkdownData.value?.markdown and if it's falsy returns early (or surfaces
an error/toast) instead of calling copy with ''—use fetchReadmeMarkdown(),
inspect readmeMarkdownData (or its Markdown field) and only call copy(async ()
=> ...) when markdown is non-empty, otherwise bail out or raise a user-visible
error.


function prefetchReadmeMarkdown() {
if (readmeMarkdownStatus.value === 'idle') {
Expand Down Expand Up @@ -1040,7 +1045,11 @@ const showSkeleton = shallowRef(false)
"
:classicon="copiedReadme ? 'i-lucide:check' : 'i-simple-icons:markdown'"
>
{{ copiedReadme ? $t('common.copied') : $t('common.copy') }}
<span>{{ copiedReadme ? $t('common.copied') : $t('common.copy') }}</span>
<span
v-if="copyReadmePending"
class="i-lucide:loader-circle animate-spin size-4"
></span>
</ButtonBase>
</TooltipApp>
<ReadmeTocDropdown
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"@vercel/speed-insights": "2.0.0",
"@vite-pwa/assets-generator": "1.0.2",
"@vite-pwa/nuxt": "1.1.1",
"@vueuse/core": "14.2.1",
"@vueuse/core": "14.3.0",
"@vueuse/integrations": "14.2.1",
"@vueuse/nuxt": "14.2.1",
"@vueuse/router": "^14.2.1",
Expand Down
34 changes: 30 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading