fix: RichText imports, formatDateTime Swedish locale, posts page styling
This commit is contained in:
parent
5ea9588223
commit
839773c271
@ -5,7 +5,9 @@ import config from '@payload-config'
|
||||
import type { Post, Media } from '@/payload-types'
|
||||
import { FDImage } from '@/components/FDImage'
|
||||
import { generateMeta } from '@/utilities/generateMeta'
|
||||
import { formatDate } from '@/utilities/formatDate'
|
||||
import { formatDateTime } from '@/utilities/formatDateTime'
|
||||
import RichText from '@/components/RichText'
|
||||
|
||||
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
type Args = {
|
||||
@ -65,7 +67,7 @@ export default async function PostPage({ params }: Args) {
|
||||
{/* Meta row */}
|
||||
<div className="flex flex-wrap items-center gap-x-6 gap-y-2 font-joey text-sm text-white/70">
|
||||
{post.publishedAt && (
|
||||
<span>{formatDate(post.publishedAt)}</span>
|
||||
<span>{formatDateTime(post.publishedAt)}</span>
|
||||
)}
|
||||
{authors.length > 0 && (
|
||||
<span>
|
||||
|
||||
@ -1,20 +1,8 @@
|
||||
export const formatDateTime = (timestamp: string): string => {
|
||||
const now = new Date()
|
||||
let date = now
|
||||
if (timestamp) date = new Date(timestamp)
|
||||
const months = date.getMonth()
|
||||
const days = date.getDate()
|
||||
// const hours = date.getHours();
|
||||
// const minutes = date.getMinutes();
|
||||
// const seconds = date.getSeconds();
|
||||
|
||||
const MM = months + 1 < 10 ? `0${months + 1}` : months + 1
|
||||
const DD = days < 10 ? `0${days}` : days
|
||||
const YYYY = date.getFullYear()
|
||||
// const AMPM = hours < 12 ? 'AM' : 'PM';
|
||||
// const HH = hours > 12 ? hours - 12 : hours;
|
||||
// const MinMin = (minutes < 10) ? `0${minutes}` : minutes;
|
||||
// const SS = (seconds < 10) ? `0${seconds}` : seconds;
|
||||
|
||||
return `${MM}/${DD}/${YYYY}`
|
||||
}
|
||||
if (!timestamp) return ''
|
||||
return new Date(timestamp).toLocaleDateString('sv-SE', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
})
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user