Skip to content

Commit c1e91e9

Browse files
committed
fixed going to latest & changed going to has to only client side
1 parent 850e5c8 commit c1e91e9

File tree

3 files changed

+50
-45
lines changed

3 files changed

+50
-45
lines changed

app/components/Changelog/Markdown.vue

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,31 @@ const { data, error } = await useFetch(
1111
() => `/api/changelog/md/${info.provider}/${info.repo}/${info.path}`,
1212
)
1313
14-
watch(
15-
[() => data.value?.toc, () => requestedVersion?.toLowerCase(), () => route.hash],
16-
([toc, rv, hash]) => {
17-
if (toc && hash) {
18-
navigateTo(hash)
19-
return
20-
}
21-
22-
if (!toc || !rv || hash) {
23-
return
24-
}
14+
if (import.meta.client) {
15+
watch(
16+
[() => data.value?.toc, () => requestedVersion?.toLowerCase(), () => route.hash],
17+
([toc, rv, hash]) => {
18+
if (toc && hash) {
19+
navigateTo(hash)
20+
return
21+
}
2522
26-
for (const item of toc) {
27-
if (item.text.toLowerCase().includes(rv)) {
28-
navigateTo(`#${item.id}`)
23+
if (!toc || !rv || hash) {
2924
return
3025
}
31-
}
32-
},
33-
{
34-
immediate: true,
35-
},
36-
)
26+
27+
for (const item of toc) {
28+
if (item.text.toLowerCase().includes(rv)) {
29+
navigateTo(`#${item.id}`)
30+
return
31+
}
32+
}
33+
},
34+
{
35+
immediate: true,
36+
},
37+
)
38+
}
3739
</script>
3840
<template>
3941
<Teleport v-if="data?.toc && data.toc.length > 1 && !!tpTarget" :to="tpTarget">

app/components/Changelog/Releases.vue

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const { data: releases, error } = await useFetch<ReleaseData[]>(
1212
)
1313
1414
const route = useRoute()
15+
const router = useRouter()
1516
1617
const matchingDateReleases = computed(() => {
1718
if (!requestedDate || !releases.value) {
@@ -28,32 +29,34 @@ const matchingDateReleases = computed(() => {
2829
})
2930
})
3031
31-
watch(
32-
[() => route.hash, () => requestedDate?.toLowerCase(), releases, () => requestedVersion],
33-
([hash, date, r, rv]) => {
34-
if (hash && r) {
35-
// ensures the user is scrolled to the hash
36-
navigateTo(hash)
37-
return
38-
}
39-
if (hash || !date || !r) {
40-
return
41-
}
42-
if (rv) {
43-
for (const match of matchingDateReleases.value ?? []) {
44-
if (match.title.toLowerCase().includes(rv)) {
45-
navigateTo(`#release-${slugify(match.title)}`)
46-
return
32+
if (import.meta.client) {
33+
watch(
34+
[() => route.hash, () => requestedDate?.toLowerCase(), releases, () => requestedVersion],
35+
([hash, date, r, rv]) => {
36+
if (hash && r) {
37+
// ensures the user is scrolled to the hash
38+
navigateTo(hash, { replace: true })
39+
return
40+
}
41+
if (hash || !date || !r) {
42+
return
43+
}
44+
if (rv) {
45+
for (const match of matchingDateReleases.value ?? []) {
46+
if (match.title.toLowerCase().includes(rv)) {
47+
navigateTo(`#release-${slugify(match.title)}`, { replace: true })
48+
return
49+
}
4750
}
4851
}
49-
}
5052
51-
navigateTo(`#date-${date}`)
52-
},
53-
{
54-
immediate: true,
55-
},
56-
)
53+
navigateTo(`#date-${date}`, { replace: true })
54+
},
55+
{
56+
immediate: true,
57+
},
58+
)
59+
}
5760
</script>
5861
<template>
5962
<div class="flex flex-col gap-2 py-3" v-if="releases">

app/pages/package-changes/[...path].vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const latestVersion = computed(() => {
5858
})
5959
6060
watch(
61-
[version, latestVersion, packageName],
61+
[version, () => latestVersion.value?.version, packageName],
6262
([v, latest, name]) => {
6363
if (!v && latest && name) {
6464
const pathSegments = [...name.split('/'), 'v', latest]
@@ -138,7 +138,7 @@ defineOgImageComponent('Default', {
138138
<SkeletonBlock class="h-5 w-3/4 max-w-2xl rounded" />
139139
</section>
140140

141-
<Suspense v-else>
141+
<Suspense v-else-if="latestVersion?.version">
142142
<template #default>
143143
<LazyChangelogReleases
144144
v-if="changelog?.type == 'release'"

0 commit comments

Comments
 (0)