File tree Expand file tree Collapse file tree 4 files changed +26
-14
lines changed Expand file tree Collapse file tree 4 files changed +26
-14
lines changed Original file line number Diff line number Diff line change @@ -19,17 +19,15 @@ const props = defineProps({
19
19
<div class =" flex-1 text-lg font-bold md:text-xl" >
20
20
{{ article.title }}
21
21
</div >
22
- <div v-if =" show_dates" class =" text-sm font-light text-gray-400" >
23
- {{
24
- new Date(article.date).toLocaleDateString("en-US", {
25
- month: "long",
26
- day: "numeric",
27
- year: "numeric",
28
- })
29
- }}
30
- </div >
22
+ <NuxtTime
23
+ v-if =" show_dates"
24
+ :datetime =" article.date"
25
+ class =" text-sm font-light text-gray-400"
26
+ year =" numeric"
27
+ month =" short"
28
+ day =" 2-digit"
29
+ />
31
30
</div >
32
-
33
31
<div class =" line-clamp-3 text-sm text-gray-300" >
34
32
{{ article.description }}
35
33
</div >
Original file line number Diff line number Diff line change @@ -91,9 +91,13 @@ function toggleCategory(cat) {
91
91
<div class =" col-span-4 lg:col-span-3" >
92
92
<div class =" grid grid-cols-10 gap-y-4 lg:gap-y-6" >
93
93
<template v-for =" article in visibleArticles " :key =" article ._id " >
94
- <div class =" col-span-10 lg:col-span-2" >
95
- {{ formatDate(article.date) }}
96
- </div >
94
+ <NuxtTime
95
+ :datetime =" article.date"
96
+ class =" col-span-10 lg:col-span-2"
97
+ year =" numeric"
98
+ month =" short"
99
+ day =" 2-digit"
100
+ />
97
101
<div class =" col-span-10 lg:col-span-8" >
98
102
<div class =" flex-col space-y-2" >
99
103
<NuxtLink class =" text-orange-500" :to =" article.path" >{{
Original file line number Diff line number Diff line change @@ -73,7 +73,13 @@ const talks = [
73
73
<h1 class =" my-6 text-2xl font-extrabold" >Talks</h1 >
74
74
<div class =" grid grid-cols-10 gap-y-6" >
75
75
<template v-for =" (talk , ix ) in talks " :key =" ix " >
76
- <div class =" col-span-2" >{{ formatDate(talk.date) }}</div >
76
+ <NuxtTime
77
+ :datetime =" talk.date"
78
+ class =" col-span-2"
79
+ year =" numeric"
80
+ month =" short"
81
+ day =" 2-digit"
82
+ />
77
83
<div class =" col-span-8" >
78
84
<div class =" flex-col space-y-2" >
79
85
<!-- <div class=""> -->
Original file line number Diff line number Diff line change
1
+ // Warning! This utility was created before becoming aware of <NuxtTime>.
2
+ //
3
+ // Date formatting can cause hydration issues due to the difference locale on server and client.
4
+ // See: https://www.leopold.is/blog/nuxt-hydration-issues-and-dates/
1
5
export const formatDate = function ( date ) {
2
6
return new Date ( date ) . toLocaleDateString ( "en-US" , {
3
7
month : "short" ,
You can’t perform that action at this time.
0 commit comments