File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<script setup lang="ts">
22import type { Author } from ' #shared/schemas/blog'
33
4- defineProps <{
4+ const props = defineProps <{
55 /** Authors of the blog post */
66 authors: Author []
77 /** Blog Title */
@@ -19,6 +19,8 @@ defineProps<{
1919 /** Whether this post is an unpublished draft */
2020 draft? : boolean
2121}>()
22+
23+ const formattedPublished = computed (() => toLocaleDateString (props .published ))
2224 </script >
2325
2426<template >
@@ -33,7 +35,7 @@ defineProps<{
3335 <!-- Text Content -->
3436 <div class =" flex-1 min-w-0 text-start gap-2" >
3537 <div class =" flex items-center gap-2" >
36- <span class =" text-xs text-fg-muted font-mono" >{{ published }}</span >
38+ <span class =" text-xs text-fg-muted font-mono" >{{ formattedPublished }}</span >
3739 <span
3840 v-if =" draft"
3941 class =" text-xs px-1.5 py-0.5 rounded badge-orange font-sans font-medium"
Original file line number Diff line number Diff line change @@ -17,18 +17,7 @@ const props = withDefaults(
1717
1818const { resolvedAuthors } = useBlueskyAuthorProfiles (props .authors )
1919
20- const formattedDate = computed (() => {
21- if (! props .date ) return ' '
22- try {
23- return new Date (props .date ).toLocaleDateString (' en-US' , {
24- year: ' numeric' ,
25- month: ' short' ,
26- day: ' numeric' ,
27- })
28- } catch {
29- return props .date
30- }
31- })
20+ const formattedDate = computed (() => toLocaleDateString (props .date ))
3221
3322const MAX_VISIBLE_AUTHORS = 2
3423
Original file line number Diff line number Diff line change @@ -4,3 +4,17 @@ export function toIsoDateString(date: Date): string {
44 const day = String ( date . getUTCDate ( ) ) . padStart ( 2 , '0' )
55 return `${ year } -${ month } -${ day } `
66}
7+
8+ export function toLocaleDateString ( date : string ) : string {
9+ if ( ! date ) return ''
10+
11+ try {
12+ return new Date ( date ) . toLocaleDateString ( 'en-US' , {
13+ year : 'numeric' ,
14+ month : 'short' ,
15+ day : 'numeric' ,
16+ } )
17+ } catch {
18+ return date
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments