Skip to content

Commit 89cae7e

Browse files
committed
for releases now also matching on version in release title for scrolling
added scroll margin classes ensuring to navigate to hash if present
1 parent 2de6f9f commit 89cae7e

3 files changed

Lines changed: 41 additions & 9 deletions

File tree

app/components/Changelog/Card.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ const formattedDate = computed(() => {
1313
1414
const cardId = computed(() => (release.publishedAt ? `date-${formattedDate.value}` : undefined))
1515
16-
const navId = computed(() => `release-${encodeURI(release.title)}:`)
16+
const navId = computed(() => `release-${encodeURI(release.title)}`)
1717
1818
function navigateToTitle() {
1919
navigateTo(`#${navId.value}`)
2020
}
2121
</script>
2222
<template>
23-
<section class="border border-border rounded-lg p-4 sm:p-6">
24-
<div class="flex gap-2 items-center" :id="cardId">
25-
<h2 class="text-1xl sm:text-2xl font-medium min-w-0 break-words py-2" :id="navId">
23+
<section class="border border-border rounded-lg p-4 sm:p-6 scroll-mt-18" :id="cardId">
24+
<div class="flex gap-2 items-center">
25+
<h2
26+
class="text-1xl sm:text-2xl font-medium min-w-0 break-words py-2 scroll-mt-20"
27+
:id="navId"
28+
>
2629
<a
2730
class="hover:decoration-accent hover:text-accent focus-visible:decoration-accent focus-visible:text-accent transition-colors duration-200"
2831
:class="$style.linkTitle"

app/components/Changelog/Releases.vue

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,52 @@
11
<script setup lang="ts">
2-
const { info, requestedDate } = defineProps<{
2+
const { info, requestedDate, requestedVersion } = defineProps<{
33
info: ChangelogReleaseInfo
44
requestedDate?: string
5+
requestedVersion?: string | null | undefined
56
}>()
67
78
const { data: releases } = useFetch<ReleaseData[]>(
89
() => `/api/changelog/releases/${info.provider}/${info.repo}`,
910
)
1011
1112
const route = useRoute()
12-
const router = useRouter()
13+
14+
const matchingDateReleases = computed(() => {
15+
if (!requestedDate || !releases.value) {
16+
return
17+
}
18+
19+
return releases.value.filter(release => {
20+
if (!release.publishedAt) {
21+
return
22+
}
23+
const date = new Date(release.publishedAt).toISOString().split('T')[0]
24+
25+
return date == requestedDate
26+
})
27+
})
1328
1429
watch(
15-
[() => route.hash, () => requestedDate, releases],
16-
([hash, date, r]) => {
30+
[() => route.hash, () => requestedDate, releases, () => requestedVersion],
31+
([hash, date, r, rv]) => {
32+
if (hash && r) {
33+
// ensures the user is scrolled to the hash
34+
navigateTo(hash)
35+
return
36+
}
1737
if (hash || !date || !r) {
1838
return
1939
}
40+
if (rv) {
41+
for (const match of matchingDateReleases.value ?? []) {
42+
if (match.title.includes(rv)) {
43+
navigateTo(`#release-${encodeURI(match.title)}`)
44+
return
45+
}
46+
}
47+
}
2048
21-
router.push(`#date-${date}`)
49+
navigateTo(`#date-${date}`)
2250
},
2351
{
2452
immediate: true,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ const versionDate = computed(() => {
127127
v-if="changelog?.type == 'release'"
128128
:info="changelog"
129129
:requestedDate="versionDate"
130+
:requested-version="version || latestVersion"
130131
/>
131132
<LazyChangelogMarkdown
132133
v-else-if="changelog?.type == 'md'"

0 commit comments

Comments
 (0)