Skip to content

Commit cbcdc54

Browse files
authored
fix: avoid showing "No README is available" during README load (#2473)
1 parent b9c3a1d commit cbcdc54

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ if (import.meta.server) {
5858
}
5959
6060
// Fetch README for specific version if requested, otherwise latest
61-
const { data: readmeData } = useLazyFetch<ReadmeResponse>(
61+
const { data: readmeData, status: readmeStatus } = useLazyFetch<ReadmeResponse>(
6262
() => {
6363
const base = `/api/registry/readme/${packageName.value}`
6464
const version = resolvedVersion.value
@@ -1047,7 +1047,20 @@ const showSkeleton = shallowRef(false)
10471047

10481048
<!-- eslint-disable vue/no-v-html -- HTML is sanitized server-side -->
10491049
<Readme v-if="readmeData?.html" :html="readmeData.html" />
1050-
<p v-else class="text-fg-muted italic">
1050+
<p
1051+
v-else-if="readmeStatus === 'pending'"
1052+
class="flex items-center gap-2 text-fg-subtle italic"
1053+
>
1054+
<span class="i-svg-spinners:ring-resize w-4 h-4" aria-hidden="true" />
1055+
<span>{{ $t('common.loading') }}…</span>
1056+
</p>
1057+
<p v-else-if="readmeStatus === 'error'" class="text-fg-muted italic">
1058+
{{ $t('package.readme.error_loading') }}
1059+
</p>
1060+
<p
1061+
v-else-if="readmeStatus === 'success' && !readmeData?.html"
1062+
class="text-fg-muted italic"
1063+
>
10511064
{{ $t('package.readme.no_readme') }}
10521065
<a
10531066
v-if="repositoryUrl"

i18n/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,8 @@
481481
"warning": "Warning",
482482
"caution": "Caution"
483483
},
484-
"copy_as_markdown": "Copy README as Markdown"
484+
"copy_as_markdown": "Copy README as Markdown",
485+
"error_loading": "Failed to load README details"
485486
},
486487
"provenance_section": {
487488
"title": "Provenance",

i18n/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,6 +1449,9 @@
14491449
},
14501450
"copy_as_markdown": {
14511451
"type": "string"
1452+
},
1453+
"error_loading": {
1454+
"type": "string"
14521455
}
14531456
},
14541457
"additionalProperties": false

0 commit comments

Comments
 (0)