@@ -5,7 +5,7 @@ definePageMeta({
55 name: ' changes' ,
66 path: ' /package-changes/:path+' ,
77 alias: [' /package/changes/:path+' , ' /changes/:path+' ],
8- scrollMargin: 150 ,
8+ scrollMargin: 200 ,
99})
1010
1111// / routing
@@ -50,7 +50,12 @@ const versionUrlPattern = computed(() => {
5050 return filePath .value ? ` ${base }/${filePath .value } ` : base
5151})
5252
53- const latestVersion = computed (() => pkg .value ?.[' dist-tags' ]?.latest ?? null )
53+ const latestVersion = computed (() => {
54+ if (! pkg .value ) return null
55+ const latestTag = pkg .value [' dist-tags' ]?.latest
56+ if (! latestTag ) return null
57+ return pkg .value .versions [latestTag ] ?? null
58+ })
5459
5560watch (
5661 [version , latestVersion , packageName ],
@@ -81,63 +86,68 @@ const versionDate = computed(() => {
8186
8287const viewOnGit = useViewOnGitProvider (() => changelog .value ?.provider )
8388
84- // defineOgImageComponent('Default', {
85- // title: () => `${pkg.value?.name ?? 'Package'} - Changelogs`,
86- // description: () => pkg.value?.license ?? '',
87- // primaryColor: '#60a5fa',
88- // })
89+ const packageHeaderHeight = usePackageHeaderHeight ()
90+ const stickyStyle = computed (() => {
91+ return {
92+ ' --combined-header-height' : ` ${50 + (packageHeaderHeight .value || 44 )}px ` ,
93+ }
94+ })
95+
96+ defineOgImageComponent (' Default' , {
97+ title : () => ` ${pkg .value ?.name ?? ' Package' } - Changelogs ` ,
98+ description : () => pkg .value ?.license ?? ' ' ,
99+ primaryColor: ' #60a5fa' ,
100+ })
89101 </script >
90102<template >
91- <main class =" flex-1 flex flex-col" >
92- <header class =" border-b border-border bg-bg sticky top-14 z-20" >
93- <div class =" container pt-4 pb-3" >
94- <div class =" flex items-center gap-3 mb-3 flex-wrap min-w-0" >
95- <h1
96- class =" font-mono text-lg sm:text-xl font-semibold text-fg hover:text-fg-muted transition-colors truncate"
97- >
98- <NuxtLink v-if =" packageName" :to =" packageRoute(packageName, version)" >
99- {{ packageName }}
100- </NuxtLink >
101- </h1 >
102-
103- <VersionSelector
104- v-if =" (version || latestVersion) && pkg?.versions && pkg?.['dist-tags']"
105- :package-name =" packageName"
106- :current-version =" version ?? latestVersion!"
107- :versions =" pkg.versions"
108- :dist-tags =" pkg['dist-tags']"
109- :url-pattern =" versionUrlPattern"
110- />
111- <div class =" flex-1" ></div >
112- <LinkBase
113- v-if =" changelog?.link"
114- :to =" changelog?.link"
115- :classicon =" repoProviderIcon"
116- :title =" viewOnGit"
117- >
118- {{ changelog.provider }}
119- </LinkBase >
120-
121- <div v-if =" changelog?.type == 'md'" ref =" tptoc" class =" w-14 h-8 ms-auto" >
122- <!-- prevents layout shift while loading -->
123- </div >
103+ <main class =" flex-1 flex flex-col" :style =" stickyStyle" >
104+ <PackageHeader
105+ page =" changes"
106+ :versionUrlPattern
107+ :pkg
108+ :latestVersion
109+ :resolved-version =" version"
110+ :display-version =" pkg?.requestedVersion"
111+ />
112+ <section class =" container w-full pt-3" v-if =" !pending" >
113+ <div
114+ class =" sticky top-[--combined-header-height] pa-3 z-2 flex justify-between gap-4"
115+ :class =" $style.gitTocHeader"
116+ >
117+ <LinkBase
118+ v-if =" changelog?.link"
119+ :to =" changelog?.link"
120+ :classicon =" repoProviderIcon"
121+ :title =" viewOnGit"
122+ >
123+ {{ changelog.provider }}
124+ </LinkBase >
125+ <div v-if =" changelog?.type == 'md'" ref =" tptoc" class =" w-14 h-8" >
126+ <!- prevents layout shift while loading - >
124127 </div >
125128 </div >
126- </header >
127- <section class =" container w-full" v-if =" !pending" >
129+
128130 <LazyChangelogReleases
129131 v-if =" changelog?.type == 'release'"
130132 :info =" changelog"
131133 :requestedDate =" versionDate"
132- :requested-version =" version || latestVersion"
134+ :requested-version =" version || latestVersion?.version "
133135 />
134136 <LazyChangelogMarkdown
135137 v-else-if =" changelog?.type == 'md'"
136138 :info =" changelog"
137139 :tpTarget =" tptoc"
138- :requested-version =" version || latestVersion"
140+ :requested-version =" version || latestVersion?.version "
139141 />
140142 <p class =" mt-5" v-else >{{ $t('changelog.no_logs') }}</p >
141143 </section >
142144 </main >
143145</template >
146+
147+ <style module>
148+ .gitTocHeader {
149+ border-bottom-width : 1px ;
150+ border-color : color-mix(in srgb , var (--border ) var (--un-border-opacity ), transparent );
151+ background-color : color-mix(in srgb , var (--bg ) var (--un-bg-opacity ), transparent );
152+ }
153+ </style >
0 commit comments