11<script setup lang="ts">
2+ import type { PackageVersionInfo } from ' #shared/types'
23import { compare } from ' semver'
34import { buildVersionToTagsMap , buildTaggedVersionRows } from ' ~/utils/versions'
45
@@ -14,23 +15,24 @@ const packageName = computed(() => {
1415 return org ? ` ${org }/${name } ` : (name as string )
1516})
1617
17- // ─── Mock data ────────────────────────────────────────────────────────────────
18- // TODO: Replace with real data from usePackage() / fetchAllPackageVersions()
18+ const orgName = computed (() => {
19+ const name = packageName .value
20+ if (! name .startsWith (' @' )) return null
21+ const match = name .match (/ ^ @([^ /] + )\/ / )
22+ return match ? match [1 ] : null
23+ })
1924
20- interface VersionEntry {
21- version: string
22- time: string
23- deprecated? : string
24- hasProvenance: boolean
25- }
25+ // ─── Mock data ────────────────────────────────────────────────────────────────
26+ // TODO: Replace distTags with pkg['dist-tags'] from usePackage()
27+ // TODO: Replace versionHistory with data from useAllPackageVersions()
2628
27- const mockDistTags : Record <string , string > = {
29+ const distTags : Record <string , string > = {
2830 ' latest' : ' 7.26.3' ,
2931 ' next' : ' 8.0.0-alpha.16' ,
3032 ' babel-7' : ' 7.26.3' ,
3133}
3234
33- const mockVersions : VersionEntry [] = [
35+ const versionHistory : PackageVersionInfo [] = [
3436 { version: ' 8.0.0-alpha.16' , time: ' 2024-12-15T10:00:00Z' , hasProvenance: true },
3537 { version: ' 8.0.0-alpha.15' , time: ' 2024-11-20T10:00:00Z' , hasProvenance: true },
3638 { version: ' 8.0.0-alpha.14' , time: ' 2024-10-30T10:00:00Z' , hasProvenance: true },
@@ -82,18 +84,18 @@ const mockVersions: VersionEntry[] = [
8284
8385// ─── Derived data ─────────────────────────────────────────────────────────────
8486
85- const versionToTagsMap = computed (() => buildVersionToTagsMap (mockDistTags ))
87+ const versionToTagsMap = computed (() => buildVersionToTagsMap (distTags ))
8688
8789const sortedVersions = computed (() =>
88- [... mockVersions ]
90+ [... versionHistory ]
8991 .sort ((a , b ) => compare (b .version , a .version ))
9092 .map (v => ({ ... v , tags: versionToTagsMap .value .get (v .version ) })),
9193)
9294
93- const tagRows = computed (() => buildTaggedVersionRows (mockDistTags ))
95+ const tagRows = computed (() => buildTaggedVersionRows (distTags ))
9496
9597function getVersionTime(version : string ): string | undefined {
96- return mockVersions .find (v => v .version === version )?.time
98+ return versionHistory .find (v => v .version === version )?.time
9799}
98100
99101// ─── Jump to version ──────────────────────────────────────────────────────────
@@ -104,7 +106,7 @@ const jumpError = ref('')
104106function navigateToVersion() {
105107 const v = jumpVersion .value .trim ()
106108 if (! v ) return
107- if (! mockVersions .some (mv => mv .version === v )) {
109+ if (! versionHistory .some (entry => entry .version === v )) {
108110 jumpError .value = ` Version "${v }" not found `
109111 return
110112 }
@@ -114,21 +116,28 @@ function navigateToVersion() {
114116 </script >
115117
116118<template >
117- <main class =" container flex-1 w-full py-8" >
118- <div class =" max-w-3xl mx-auto" >
119- <!-- Back link -->
120- <div class =" mb-6" >
121- <LinkBase :to =" packageRoute(packageName)" classicon =" i-lucide:arrow-left" class =" text-sm" >
122- <span class =" font-mono" dir =" ltr" >{{ packageName }}</span >
123- </LinkBase >
119+ <main class =" flex-1 flex flex-col" >
120+ <!-- Header (same pattern as code/docs pages) -->
121+ <header class =" border-b border-border bg-bg sticky top-14 z-20" >
122+ <div class =" container py-4" >
123+ <div class =" flex items-center gap-2 min-w-0" >
124+ <NuxtLink
125+ :to =" packageRoute(packageName)"
126+ class =" font-mono text-lg font-medium hover:text-fg-muted transition-colors min-w-0 truncate"
127+ :title =" packageName"
128+ dir =" ltr"
129+ >
130+ <span v-if =" orgName" class =" text-fg-muted" >@{{ orgName }}/</span
131+ >{{ orgName ? packageName.replace(`@${orgName}/`, '') : packageName }}
132+ </NuxtLink >
133+ <span class =" text-fg-subtle shrink-0" >/</span >
134+ <span class =" font-mono text-sm text-fg-muted shrink-0" >Version History</span >
135+ </div >
124136 </div >
137+ </header >
125138
126- <!-- Page heading -->
127- <h1 class =" font-mono text-2xl sm:text-3xl font-medium mb-8" dir =" ltr" >
128- {{ packageName }}
129- <span class =" text-fg-muted font-normal text-lg sm:text-2xl ms-2" >· Version History</span >
130- </h1 >
131-
139+ <!-- Content -->
140+ <div class =" container max-w-3xl py-8" >
132141 <!-- ── Current Tags ─────────────────────────────────────────────────── -->
133142 <section class =" mb-10" >
134143 <h2 class =" text-xs text-fg-subtle uppercase tracking-wider mb-3 ps-1" >Current Tags</h2 >
0 commit comments