Skip to content

Commit 036ce05

Browse files
committed
fix: use <NuxtTime> and improve a11y
1 parent ffbd262 commit 036ce05

1 file changed

Lines changed: 14 additions & 19 deletions

File tree

app/pages/[...package].vue

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,6 @@ function normalizeGitUrl(url: string): string {
156156
.replace(/^git@github\.com:/, 'https://github.com/')
157157
}
158158
159-
function formatDate(dateStr: string): string {
160-
return new Date(dateStr).toLocaleDateString('en-US', {
161-
year: 'numeric',
162-
month: 'short',
163-
day: 'numeric',
164-
})
165-
}
166-
167159
function formatBytes(bytes: number): string {
168160
if (bytes < 1024) return `${bytes} B`
169161
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} kB`
@@ -354,7 +346,7 @@ defineOgImageComponent('Package', {
354346
>
355347
<button
356348
type="button"
357-
class="font-mono text-xs text-fg-muted hover:text-fg bg-bg px-1 transition-colors duration-200"
349+
class="font-mono text-xs text-fg-muted hover:text-fg bg-bg px-1 transition-colors duration-200 rounded focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50"
358350
@click="descriptionExpanded = true"
359351
>
360352
show more
@@ -431,7 +423,10 @@ defineOgImageComponent('Package', {
431423
v-if="installSizeStatus === 'pending'"
432424
class="inline-flex items-center gap-1 text-fg-subtle"
433425
>
434-
<span class="i-carbon-circle-dash w-3 h-3 animate-spin" aria-hidden="true" />
426+
<span
427+
class="i-carbon-circle-dash w-3 h-3 animate-spin motion-reduce:animate-none"
428+
aria-hidden="true"
429+
/>
435430
</span>
436431
<span v-else-if="installSize?.totalSize">
437432
{{ formatBytes(installSize.totalSize) }}
@@ -443,7 +438,7 @@ defineOgImageComponent('Package', {
443438
<div v-if="pkg.time?.modified" class="space-y-1">
444439
<dt class="text-xs text-fg-subtle uppercase tracking-wider">Updated</dt>
445440
<dd class="font-mono text-sm text-fg">
446-
<time :datetime="pkg.time.modified">{{ formatDate(pkg.time.modified) }}</time>
441+
<NuxtTime :datetime="pkg.time.modified" date-style="medium" />
447442
</dd>
448443
</div>
449444
</dl>
@@ -458,7 +453,7 @@ defineOgImageComponent('Package', {
458453
rel="noopener noreferrer"
459454
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
460455
>
461-
<span class="i-carbon-logo-github w-4 h-4" />
456+
<span class="i-carbon-logo-github w-4 h-4" aria-hidden="true" />
462457
repo
463458
</a>
464459
</li>
@@ -469,7 +464,7 @@ defineOgImageComponent('Package', {
469464
rel="noopener noreferrer"
470465
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
471466
>
472-
<span class="i-carbon-link w-4 h-4" />
467+
<span class="i-carbon-link w-4 h-4" aria-hidden="true" />
473468
homepage
474469
</a>
475470
</li>
@@ -480,7 +475,7 @@ defineOgImageComponent('Package', {
480475
rel="noopener noreferrer"
481476
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
482477
>
483-
<span class="i-carbon-warning w-4 h-4" />
478+
<span class="i-carbon-warning w-4 h-4" aria-hidden="true" />
484479
issues
485480
</a>
486481
</li>
@@ -491,7 +486,7 @@ defineOgImageComponent('Package', {
491486
rel="noopener noreferrer"
492487
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
493488
>
494-
<span class="i-carbon-cube w-4 h-4" />
489+
<span class="i-carbon-cube w-4 h-4" aria-hidden="true" />
495490
npm
496491
</a>
497492
</li>
@@ -503,7 +498,7 @@ defineOgImageComponent('Package', {
503498
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
504499
title="Also available on JSR"
505500
>
506-
<span class="i-simple-icons-jsr w-4 h-4" />
501+
<span class="i-simple-icons-jsr w-4 h-4" aria-hidden="true" />
507502
jsr
508503
</a>
509504
</li>
@@ -514,7 +509,7 @@ defineOgImageComponent('Package', {
514509
rel="noopener noreferrer"
515510
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
516511
>
517-
<span class="i-simple-icons-socket w-4 h-4" />
512+
<span class="i-simple-icons-socket w-4 h-4" aria-hidden="true" />
518513
socket.dev
519514
</a>
520515
</li>
@@ -527,7 +522,7 @@ defineOgImageComponent('Package', {
527522
}"
528523
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
529524
>
530-
<span class="i-carbon-code w-4 h-4" />
525+
<span class="i-carbon-code w-4 h-4" aria-hidden="true" />
531526
code
532527
</NuxtLink>
533528
</li>
@@ -609,7 +604,7 @@ defineOgImageComponent('Package', {
609604
</div>
610605
</div>
611606
<button
612-
class="absolute top-3 right-3 px-2 py-1 font-mono text-xs text-fg-muted bg-bg-subtle/80 border border-border rounded transition-all duration-200 hover:(text-fg border-border-hover) active:scale-95"
607+
class="absolute top-3 right-3 px-2 py-1 font-mono text-xs text-fg-muted bg-bg-subtle/80 border border-border rounded transition-colors duration-200 hover:(text-fg border-border-hover) active:scale-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50"
613608
@click="copyInstallCommand"
614609
>
615610
{{ copied ? 'copied!' : 'copy' }}

0 commit comments

Comments
 (0)