Skip to content

Commit 133aa39

Browse files
committed
now also matching to version with changelog.md
1 parent bdcf1a7 commit 133aa39

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

app/components/Changelog/Markdown.vue

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,37 @@
11
<script setup lang="ts">
2-
const { info, tpTarget } = defineProps<{
2+
const { info, requestedVersion, tpTarget } = defineProps<{
33
info: ChangelogMarkdownInfo
4+
requestedVersion: string | null
45
tpTarget?: HTMLElement | null
56
}>()
67
8+
const route = useRoute()
9+
710
const { data } = useLazyFetch(() => `/api/changelog/md/${info.provider}/${info.repo}/${info.path}`)
11+
12+
watch(
13+
[() => data.value?.toc, () => requestedVersion?.toLowerCase(), () => route.hash],
14+
([toc, rv, hash]) => {
15+
if (toc && hash) {
16+
navigateTo(hash)
17+
return
18+
}
19+
20+
if (!toc || !rv || hash) {
21+
return
22+
}
23+
24+
for (const item of toc) {
25+
if (item.text.toLowerCase().includes(rv)) {
26+
navigateTo(`#${item.id}`)
27+
return
28+
}
29+
}
30+
},
31+
{
32+
immediate: true,
33+
},
34+
)
835
</script>
936
<template>
1037
<Teleport v-if="data?.toc && data.toc.length > 1 && !!tpTarget" :to="tpTarget">

app/components/Changelog/Releases.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const matchingDateReleases = computed(() => {
2727
})
2828
2929
watch(
30-
[() => route.hash, () => requestedDate, releases, () => requestedVersion],
30+
[() => route.hash, () => requestedDate?.toLowerCase(), releases, () => requestedVersion],
3131
([hash, date, r, rv]) => {
3232
if (hash && r) {
3333
// ensures the user is scrolled to the hash
@@ -39,7 +39,7 @@ watch(
3939
}
4040
if (rv) {
4141
for (const match of matchingDateReleases.value ?? []) {
42-
if (match.title.includes(rv)) {
42+
if (match.title.toLowerCase().includes(rv)) {
4343
navigateTo(`#release-${encodeURI(match.title)}`)
4444
return
4545
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ const versionDate = computed(() => {
133133
v-else-if="changelog?.type == 'md'"
134134
:info="changelog"
135135
:tpTarget="tptoc"
136+
:requested-version="version || latestVersion"
136137
/>
137138
<p class="mt-5" v-else>{{ $t('changelog.no_logs') }}</p>
138139
</section>

0 commit comments

Comments
 (0)