|
17 | 17 | | Awaited<NonNullable<typeof data.prs>>[number] |
18 | 18 | | Awaited<NonNullable<typeof data.discussions>>[number]; |
19 | 19 |
|
| 20 | + const daysAgoFormatter = new Intl.RelativeTimeFormat("en", { numeric: "auto" }); |
| 21 | + const shortDateFormatter = new Intl.DateTimeFormat("en", { dateStyle: "medium" }); |
| 22 | +
|
20 | 23 | /** |
21 | 24 | * Checks whether a date is more recent than a month. |
22 | 25 | * |
|
35 | 38 | */ |
36 | 39 | function daysAgo(date: Date) { |
37 | 40 | const days = Math.floor((Date.now() - date.getTime()) / 1000 / 60 / 60 / 24); |
38 | | - return new Intl.RelativeTimeFormat("en", { numeric: "auto" }).format(-days, "day"); |
| 41 | + return daysAgoFormatter.format(-days, "day"); |
39 | 42 | } |
40 | 43 |
|
41 | 44 | /** |
|
84 | 87 | <!-- prettier-ignore --> |
85 | 88 | {#snippet listItem(item: Item, link: string)} |
86 | 89 | {@const lastUpdate = new Date(item.updated_at)} |
87 | | - {@const isUpdated = !areSameDay(lastUpdate, new Date(item.created_at))} |
| 90 | + {@const createdAt = new Date(item.created_at)} |
| 91 | + {@const isUpdated = !areSameDay(lastUpdate, createdAt)} |
88 | 92 |
|
89 | 93 | <!-- eslint-disable-next-line svelte/no-navigation-without-resolve --> |
90 | 94 | <a href={link} class="flex items-center gap-6 rounded-md px-4 py-3 transition-colors hover:bg-neutral-100 dark:hover:bg-neutral-800"> |
|
114 | 118 | <MarkdownRenderer markdown={item.title} inline class="text-foreground" /> |
115 | 119 | <span class="text-muted-foreground">#{item.number}</span> |
116 | 120 | </span> |
117 | | - <span class="text-right"> |
118 | | - {#if isNew(lastUpdate)} |
119 | | - {daysAgo(lastUpdate)} • |
| 121 | + <span class="text-right text-nowrap"> |
| 122 | + {#if isUpdated && isNew(lastUpdate)} |
| 123 | + <span class="italic font-semibold">updated {daysAgo(lastUpdate)}</span> • |
120 | 124 | {/if} |
121 | | - <span class={{ italic: isUpdated }}> |
122 | | - {new Intl.DateTimeFormat("en", { |
123 | | - dateStyle: "medium" |
124 | | - }).format(lastUpdate)} |
125 | | - </span> |
| 125 | + <span>{shortDateFormatter.format(createdAt)}</span> |
126 | 126 | </span> |
127 | 127 | </div> |
128 | 128 | <MarkdownRenderer |
|
154 | 154 | > |
155 | 155 | {#snippet img({ alt })} |
156 | 156 | <div> |
157 | | - <Image class="inline-block h-lh" /> |
| 157 | + <Image class="inline-block h-[.9lh]" /> |
158 | 158 | {alt} |
159 | 159 | </div> |
160 | 160 | {/snippet} |
|
0 commit comments