Skip to content

Commit 1d739f7

Browse files
committed
fix: skills SSR + code viewer race condition
1 parent a7646ef commit 1d739f7

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ const {
7070
)
7171
onMounted(() => fetchInstallSize())
7272
73-
// Fetch skills data (lazy, client-side)
73+
// Fetch skills data
7474
const { data: skillsData } = useLazyFetch<SkillsListResponse>(
7575
() => {
7676
const base = `/skills/${packageName.value}`
7777
const version = requestedVersion.value
7878
return version ? `${base}/v/${version}` : base
7979
},
80-
{ server: false, default: () => ({ package: '', version: '', skills: [] }) },
80+
{ default: () => ({ package: '', version: '', skills: [] }) },
8181
)
8282
8383
const { data: packageAnalysis } = usePackageAnalysis(packageName, requestedVersion)

app/pages/code/[...path].vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,18 @@ const fileContentUrl = computed(() => {
9898
return `/api/registry/file/${packageName.value}/v/${version.value}/${filePath.value}`
9999
})
100100
101-
const { data: fileContent, status: fileStatus } = useFetch<PackageFileContentResponse>(
102-
() => fileContentUrl.value!,
103-
{ immediate: !!fileContentUrl.value },
101+
const {
102+
data: fileContent,
103+
status: fileStatus,
104+
execute: fetchFileContent,
105+
} = useFetch<PackageFileContentResponse>(() => fileContentUrl.value!, { immediate: false })
106+
107+
watch(
108+
fileContentUrl,
109+
url => {
110+
if (url) fetchFileContent()
111+
},
112+
{ immediate: true },
104113
)
105114
106115
// Track hash manually since we update it via history API to avoid scroll

0 commit comments

Comments
 (0)