news widget
This commit is contained in:
parent
4678ec0cc9
commit
8d416c78d8
@ -56,6 +56,12 @@ export function News() {
|
|||||||
const formatDate = (dateString: string) => {
|
const formatDate = (dateString: string) => {
|
||||||
try {
|
try {
|
||||||
const date = new Date(dateString);
|
const date = new Date(dateString);
|
||||||
|
|
||||||
|
// Check if date is valid before using formatDistance
|
||||||
|
if (isNaN(date.getTime())) {
|
||||||
|
return dateString; // Return original string if date is invalid
|
||||||
|
}
|
||||||
|
|
||||||
return formatDistance(date, new Date(), {
|
return formatDistance(date, new Date(), {
|
||||||
addSuffix: true,
|
addSuffix: true,
|
||||||
locale: fr
|
locale: fr
|
||||||
@ -122,7 +128,7 @@ export function News() {
|
|||||||
<h3 className="text-sm font-medium text-gray-800 line-clamp-2" title={item.title}>
|
<h3 className="text-sm font-medium text-gray-800 line-clamp-2" title={item.title}>
|
||||||
{item.title}
|
{item.title}
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-xs text-gray-500 line-clamp-2" title={item.description}>
|
<p className="text-xs text-gray-500 line-clamp-2" title={item.description || undefined}>
|
||||||
{item.description}
|
{item.description}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user