fix:update publishedAt detail

This commit is contained in:
Anang Yusman 2026-01-23 15:23:37 +08:00
parent b287069d30
commit 1b8ef91a72
5 changed files with 117 additions and 64 deletions

View File

@ -86,7 +86,7 @@ export default function DetailContent() {
const [diseId, setDiseId] = useState(0); const [diseId, setDiseId] = useState(0);
const [thumbnailImg, setThumbnailImg] = useState<File[]>([]); const [thumbnailImg, setThumbnailImg] = useState<File[]>([]);
const [selectedMainImage, setSelectedMainImage] = useState<number | null>( const [selectedMainImage, setSelectedMainImage] = useState<number | null>(
null null,
); );
const [selectedIndex, setSelectedIndex] = useState(0); const [selectedIndex, setSelectedIndex] = useState(0);
@ -325,7 +325,7 @@ export default function DetailContent() {
// 3⃣ FILTER sesuai articleId // 3⃣ FILTER sesuai articleId
const filteredFiles = allFiles.filter( const filteredFiles = allFiles.filter(
(file: any) => file.articleId === data.id (file: any) => file.articleId === data.id,
); );
setDetailFiles(filteredFiles); setDetailFiles(filteredFiles);
@ -397,16 +397,22 @@ export default function DetailContent() {
</span> </span>
<span></span> <span></span>
<span> <span>
<span> {new Date(
{new Date( articleDetail?.publishedAt ?? articleDetail?.publishedAt,
articleDetail?.publishedAt ?? articleDetail?.createdAt )
).toLocaleDateString("id-ID", { .toLocaleString("id-ID", {
day: "numeric", day: "numeric",
month: "long", month: "long",
year: "numeric", year: "numeric",
})} hour: "2-digit",
</span> minute: "2-digit",
hour12: false,
timeZone: "Asia/Jakarta",
})
.replace("pukul ", "")}{" "}
WIB
</span> </span>
<span></span> <span></span>
<span>{articleDetail?.categories?.[0]?.title}</span> <span>{articleDetail?.categories?.[0]?.title}</span>
</div> </div>
@ -527,7 +533,7 @@ export default function DetailContent() {
<div <div
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{
__html: decodeHtmlString( __html: decodeHtmlString(
articleDetail?.htmlDescription || "" articleDetail?.htmlDescription || "",
), ),
}} }}
/> />

View File

@ -10,6 +10,7 @@ type Article = {
id: number; id: number;
title: string; title: string;
description: string; description: string;
publishedAt: string;
categoryName: string; categoryName: string;
createdAt: string; createdAt: string;
createdByName: string; createdByName: string;
@ -155,14 +156,18 @@ export default function HeroNewsSection() {
/> />
</g> </g>
</svg>{" "} </svg>{" "}
{new Date(articles[0].createdAt).toLocaleDateString( {new Date(articles[0].publishedAt)
"id-ID", .toLocaleString("id-ID", {
{
day: "numeric", day: "numeric",
month: "long", month: "long",
year: "numeric", year: "numeric",
} hour: "2-digit",
)} minute: "2-digit",
hour12: false,
timeZone: "Asia/Jakarta",
})
.replace("pukul ", "")}{" "}
WIB
</p> </p>
</div> </div>
</Link> </Link>

View File

@ -171,6 +171,7 @@ type Article = {
title: string; title: string;
description: string; description: string;
categoryName: string; categoryName: string;
publishedAt: string;
createdAt: string; createdAt: string;
createdByName: string; createdByName: string;
slug: string; slug: string;
@ -239,7 +240,7 @@ export default function LatestandPopular() {
const startIndex = (currentPage - 1) * ITEMS_PER_PAGE; const startIndex = (currentPage - 1) * ITEMS_PER_PAGE;
const currentArticles = articles.slice( const currentArticles = articles.slice(
startIndex, startIndex,
startIndex + ITEMS_PER_PAGE startIndex + ITEMS_PER_PAGE,
); );
return ( return (
<section className="bg-white py-10 px-4 md:px-10 w-full"> <section className="bg-white py-10 px-4 md:px-10 w-full">
@ -301,14 +302,18 @@ export default function LatestandPopular() {
/> />
</g> </g>
</svg>{" "} </svg>{" "}
{new Date(article?.createdAt).toLocaleDateString( {new Date(article?.publishedAt)
"id-ID", .toLocaleString("id-ID", {
{
day: "numeric", day: "numeric",
month: "long", month: "long",
year: "numeric", year: "numeric",
} hour: "2-digit",
)} minute: "2-digit",
hour12: false,
timeZone: "Asia/Jakarta",
})
.replace("pukul ", "")}{" "}
WIB
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
className="h-4 w-4" className="h-4 w-4"
@ -401,14 +406,18 @@ export default function LatestandPopular() {
/> />
</g> </g>
</svg>{" "} </svg>{" "}
{new Date(articles[0]?.createdAt).toLocaleDateString( {new Date(articles[0]?.publishedAt)
"id-ID", .toLocaleString("id-ID", {
{
day: "numeric", day: "numeric",
month: "long", month: "long",
year: "numeric", year: "numeric",
} hour: "2-digit",
)} minute: "2-digit",
hour12: false,
timeZone: "Asia/Jakarta",
})
.replace("pukul ", "")}{" "}
WIB
</p> </p>
</div> </div>
</Link> </Link>
@ -452,14 +461,18 @@ export default function LatestandPopular() {
/> />
</g> </g>
</svg>{" "} </svg>{" "}
{new Date(articles[0]?.createdAt).toLocaleDateString( {new Date(articles[0]?.publishedAt)
"id-ID", .toLocaleString("id-ID", {
{
day: "numeric", day: "numeric",
month: "long", month: "long",
year: "numeric", year: "numeric",
} hour: "2-digit",
)} minute: "2-digit",
hour12: false,
timeZone: "Asia/Jakarta",
})
.replace("pukul ", "")}{" "}
WIB
</p> </p>
</div> </div>
</Link> </Link>

View File

@ -176,6 +176,7 @@ type Article = {
id: number; id: number;
title: string; title: string;
description: string; description: string;
publishedAt: string;
categoryName: string; categoryName: string;
createdAt: string; createdAt: string;
slug: string; slug: string;
@ -278,14 +279,18 @@ export default function Latest({ id }: { id: number }) {
/> />
</g> </g>
</svg>{" "} </svg>{" "}
{new Date(articles[0]?.createdAt).toLocaleDateString( {new Date(articles[0]?.publishedAt)
"id-ID", .toLocaleString("id-ID", {
{
day: "numeric", day: "numeric",
month: "long", month: "long",
year: "numeric", year: "numeric",
} hour: "2-digit",
)} minute: "2-digit",
hour12: false,
timeZone: "Asia/Jakarta",
})
.replace("pukul ", "")}{" "}
WIB
</p> </p>
</div> </div>
</Link> </Link>
@ -325,14 +330,18 @@ export default function Latest({ id }: { id: number }) {
/> />
</g> </g>
</svg>{" "} </svg>{" "}
{new Date(articles[0]?.createdAt).toLocaleDateString( {new Date(articles[0]?.publishedAt)
"id-ID", .toLocaleString("id-ID", {
{
day: "numeric", day: "numeric",
month: "long", month: "long",
year: "numeric", year: "numeric",
} hour: "2-digit",
)} minute: "2-digit",
hour12: false,
timeZone: "Asia/Jakarta",
})
.replace("pukul ", "")}{" "}
WIB
</p> </p>
</div> </div>
</Link> </Link>
@ -373,14 +382,18 @@ export default function Latest({ id }: { id: number }) {
/> />
</g> </g>
</svg>{" "} </svg>{" "}
{new Date(articles[0]?.createdAt).toLocaleDateString( {new Date(articles[0]?.publishedAt)
"id-ID", .toLocaleString("id-ID", {
{
day: "numeric", day: "numeric",
month: "long", month: "long",
year: "numeric", year: "numeric",
} hour: "2-digit",
)} minute: "2-digit",
hour12: false,
timeZone: "Asia/Jakarta",
})
.replace("pukul ", "")}{" "}
WIB
</p> </p>
</div> </div>
</Link> </Link>
@ -420,14 +433,18 @@ export default function Latest({ id }: { id: number }) {
/> />
</g> </g>
</svg>{" "} </svg>{" "}
{new Date(articles[0]?.createdAt).toLocaleDateString( {new Date(articles[0]?.publishedAt)
"id-ID", .toLocaleString("id-ID", {
{
day: "numeric", day: "numeric",
month: "long", month: "long",
year: "numeric", year: "numeric",
} hour: "2-digit",
)} minute: "2-digit",
hour12: false,
timeZone: "Asia/Jakarta",
})
.replace("pukul ", "")}{" "}
WIB
</p> </p>
</div> </div>
</Link> </Link>
@ -502,14 +519,18 @@ export default function Latest({ id }: { id: number }) {
/> />
</g> </g>
</svg>{" "} </svg>{" "}
{new Date(articles[0]?.createdAt).toLocaleDateString( {new Date(articles[0]?.publishedAt)
"id-ID", .toLocaleString("id-ID", {
{
day: "numeric", day: "numeric",
month: "long", month: "long",
year: "numeric", year: "numeric",
} hour: "2-digit",
)} minute: "2-digit",
hour12: false,
timeZone: "Asia/Jakarta",
})
.replace("pukul ", "")}{" "}
WIB
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
className="h-4 w-4" className="h-4 w-4"

View File

@ -10,6 +10,7 @@ type postsData = {
id: number; id: number;
title: string; title: string;
description: string; description: string;
publishedAt: string;
categoryName: string; categoryName: string;
createdAt: string; createdAt: string;
slug: string; slug: string;
@ -118,8 +119,8 @@ export default function Beranda() {
{posts {posts
.filter((post) => .filter((post) =>
post.categories?.some( post.categories?.some(
(category) => category.title.toLowerCase() === "pembangunan" (category) => category.title.toLowerCase() === "pembangunan",
) ),
) )
.slice(0, 6) // Ambil 4 artikel pertama setelah difilter .slice(0, 6) // Ambil 4 artikel pertama setelah difilter
.map((post, index) => ( .map((post, index) => (
@ -150,11 +151,18 @@ export default function Beranda() {
<Clock className="w-3 h-3" /> <Clock className="w-3 h-3" />
<span> <span>
{post?.customCreatorName || post.createdByName} -{" "} {post?.customCreatorName || post.createdByName} -{" "}
{new Date(post.createdAt).toLocaleDateString("id-ID", { {new Date(post.publishedAt)
day: "numeric", .toLocaleString("id-ID", {
month: "long", day: "numeric",
year: "numeric", month: "long",
})} year: "numeric",
hour: "2-digit",
minute: "2-digit",
hour12: false,
timeZone: "Asia/Jakarta",
})
.replace("pukul ", "")}{" "}
WIB
</span> </span>
</div> </div>
</div> </div>
@ -207,8 +215,8 @@ export default function Beranda() {
{posts {posts
.filter((post) => .filter((post) =>
post.categories?.some( post.categories?.some(
(category) => category.title.toLowerCase() === "kesehatan" (category) => category.title.toLowerCase() === "kesehatan",
) ),
) )
.slice(0, 6) // Ambil 4 artikel pertama setelah difilter .slice(0, 6) // Ambil 4 artikel pertama setelah difilter
.map((post, index) => ( .map((post, index) => (