This commit is contained in:
Anang Yusman 2025-11-21 16:21:01 +08:00
parent 87528c9870
commit ed583124f8
8 changed files with 112 additions and 32 deletions

View File

@ -30,6 +30,7 @@ type Article = {
description: string;
categoryName: string;
createdAt: string;
publishedAt: string;
slug: string;
createdByName: string;
customCreatorName: string;
@ -278,6 +279,23 @@ export default function DetailContent() {
);
}
function decodeHtmlString(raw: string = "") {
if (!raw) return "";
// 1⃣ Hapus newline escape, backslash, dsb
let decoded = raw
.replace(/\\n/g, "\n")
.replace(/\\"/g, '"') // ubah \" jadi "
.replace(/\\'/g, "'") // ubah \' jadi '
.replace(/\\\\/g, "\\") // ubah \\ jadi \
.trim();
// 2⃣ Decode entity HTML (misal ")
const el = document.createElement("textarea");
el.innerHTML = decoded;
return el.value;
}
return (
<>
<div className="bg-white grid grid-cols-1 md:grid-cols-3 gap-6 px-8 py-8">
@ -479,9 +497,9 @@ export default function DetailContent() {
</svg>
</Link>
</div>
<p className="text-sm text-gray-500 mt-2 text-start">
{/* <p className="text-sm text-gray-500 mt-2 text-start">
{articleDetail?.slug}
</p>
</p> */}
</div>
<div className="flex relative">
<div className="flex-1 overflow-y-auto">
@ -489,8 +507,13 @@ export default function DetailContent() {
{/* <span className="text-black font-bold text-md">
Mikulnews.com -
</span> */}
{articleDetail?.description}
<div
dangerouslySetInnerHTML={{
__html: decodeHtmlString(
articleDetail?.htmlDescription || ""
),
}}
/>
</p>
<div className="w-full bg-white py-6">
<p className="mx-10 text-2xl mb-4 ">AUTHOR</p>
@ -737,7 +760,7 @@ export default function DetailContent() {
<div className="flex items-center text-xs text-gray-500 mt-1 space-x-2">
<span>
📅{" "}
{new Date(article.createdAt).toLocaleDateString(
{new Date(article.publishedAt).toLocaleDateString(
"id-ID",
{
day: "2-digit",

View File

@ -12,6 +12,7 @@ type Article = {
categoryName: string;
slug: string;
createdAt: string;
publishedAt: string;
createdByName: string;
thumbnailUrl: string;
categories: { title: string }[];
@ -93,11 +94,14 @@ export default function HeaderEkonomi() {
</p>
<p className="text-sm text-gray-700 mt-4">
By <strong>{article.createdByName}</strong> {" "}
{new Date(article.createdAt).toLocaleDateString("en-US", {
{new Date(article.publishedAt).toLocaleDateString(
"en-US",
{
month: "long",
day: "numeric",
year: "numeric",
})}
}
)}
</p>
<Link
href={`/details/${article.slug}`}
@ -149,7 +153,7 @@ export default function HeaderEkonomi() {
{post.title}
</h5>
<p className="text-xs text-gray-500 mt-1">
{new Date(post.createdAt).toLocaleDateString("en-US", {
{new Date(post.publishedAt).toLocaleDateString("en-US", {
month: "long",
day: "numeric",
year: "numeric",

View File

@ -12,6 +12,8 @@ type Article = {
categoryName: string;
slug: string;
createdAt: string;
publishedAt: string;
createdByName: string;
thumbnailUrl: string;
categories: { title: string }[];
@ -92,11 +94,14 @@ export default function HeaderHealth() {
</p>
<p className="text-sm text-gray-700 mt-4">
By <strong>{article.createdByName}</strong> {" "}
{new Date(article.createdAt).toLocaleDateString("en-US", {
{new Date(article.publishedAt).toLocaleDateString(
"en-US",
{
month: "long",
day: "numeric",
year: "numeric",
})}
}
)}
</p>
<Link
href={`/details/${article.slug}`}
@ -148,7 +153,7 @@ export default function HeaderHealth() {
{post.title}
</h5>
<p className="text-xs text-gray-500 mt-1">
{new Date(post.createdAt).toLocaleDateString("en-US", {
{new Date(post.publishedAt).toLocaleDateString("en-US", {
month: "long",
day: "numeric",
year: "numeric",

View File

@ -12,6 +12,7 @@ type Article = {
slug: string;
categoryName: string;
createdAt: string;
publishedAt: string;
createdByName: string;
thumbnailUrl: string;
categories: { title: string }[];
@ -92,11 +93,14 @@ export default function HeaderNarrative() {
</p>
<p className="text-sm text-gray-700 mt-4">
By <strong>{article.createdByName}</strong> {" "}
{new Date(article.createdAt).toLocaleDateString("en-US", {
{new Date(article.publishedAt).toLocaleDateString(
"en-US",
{
month: "long",
day: "numeric",
year: "numeric",
})}
}
)}
</p>
<Link
href={`/details/${article.slug}`}
@ -148,7 +152,7 @@ export default function HeaderNarrative() {
{post.title}
</h5>
<p className="text-xs text-gray-500 mt-1">
{new Date(post.createdAt).toLocaleDateString("en-US", {
{new Date(post.publishedAt).toLocaleDateString("en-US", {
month: "long",
day: "numeric",
year: "numeric",

View File

@ -13,6 +13,7 @@ type Article = {
categoryName: string;
slug: string;
createdAt: string;
publishedAt: string;
createdByName: string;
thumbnailUrl: string;
categories: {
@ -93,7 +94,7 @@ export default function Beranda() {
<div className="flex items-center text-white text-xs gap-2">
<CalendarDays size={14} />
<span>
{new Date(item.createdAt).toLocaleDateString("id-ID", {
{new Date(item.publishedAt).toLocaleDateString("id-ID", {
day: "2-digit",
month: "long",
year: "numeric",

View File

@ -12,6 +12,7 @@ type Article = {
description: string;
categoryName: string;
createdAt: string;
publishedAt: string;
createdByName: string;
slug: string;
thumbnailUrl: string;
@ -126,7 +127,13 @@ const MoreNews = () => {
</h3>
<p className="text-gray-500 text-xs flex items-center gap-1">
<Timer className="text-teal-600" size={15} />
{item.createdAt}
<span>
{new Date(item?.publishedAt).toLocaleDateString("id-ID", {
day: "numeric",
month: "long",
year: "numeric",
})}
</span>
</p>
</Link>
</div>

View File

@ -174,6 +174,7 @@ type Article = {
description: string;
categoryName: string;
createdAt: string;
publishedAt: string;
createdByName: string;
slug: string;
customCreatorName: string;
@ -313,7 +314,7 @@ export default function News() {
<div className="flex items-center text-white text-xs gap-2 mt-2">
<CalendarDays size={14} />
<span>
{new Date(item.createdAt).toLocaleDateString("id-ID", {
{new Date(item.publishedAt).toLocaleDateString("id-ID", {
day: "2-digit",
month: "long",
year: "numeric",
@ -344,7 +345,14 @@ export default function News() {
</h4>
<div className="flex items-center text-xs text-gray-500 gap-2 mt-1">
<CalendarDays size={12} />
<span>{item.createdAt}</span>
<span>
{" "}
{new Date(item.publishedAt).toLocaleDateString("id-ID", {
day: "2-digit",
month: "long",
year: "numeric",
})}
</span>
</div>
</div>
</Link>
@ -434,7 +442,7 @@ export default function News() {
<CalendarDays size={14} />
<span>
{new Date(
articles[0]?.createdAt || ""
articles[0]?.publishedAt || ""
).toLocaleDateString("id-ID", {
day: "2-digit",
month: "long",
@ -481,7 +489,16 @@ export default function News() {
BY <span className="text-[#49C5C4]">ADMIN</span>
</span>
<Timer className="text-[#49C5C4]" size={12} />
<span>{item.createdAt}</span>
<span>
{new Date(item?.publishedAt || "").toLocaleDateString(
"id-ID",
{
day: "2-digit",
month: "long",
year: "numeric",
}
)}
</span>
</div>
</div>
</Link>
@ -561,7 +578,16 @@ export default function News() {
</span>
</span>
<span></span>
<span>{post.createdAt}</span>
<span>
{new Date(post?.publishedAt || "").toLocaleDateString(
"id-ID",
{
day: "2-digit",
month: "long",
year: "numeric",
}
)}
</span>
<span></span>
<MessageCircle size={14} className="text-[#49C5C4]" />
<span>{/* {post.comments} */}0</span>
@ -637,7 +663,16 @@ export default function News() {
</span>
</span>
<span></span>
<span>{post.createdAt}</span>
<span>
{new Date(post?.publishedAt || "").toLocaleDateString(
"id-ID",
{
day: "2-digit",
month: "long",
year: "numeric",
}
)}
</span>
<span></span>
<MessageCircle size={14} className="text-[#49C5C4]" />
<span>{/* {post.comments} */}0</span>

View File

@ -11,6 +11,7 @@ type Article = {
description: string;
categoryName: string;
createdAt: string;
publishedAt: string;
createdByName: string;
thumbnailUrl: string;
slug: string;
@ -134,7 +135,7 @@ const TravelNews = () => {
{item.title}
</h3>
<p className="text-white text-sm mt-2">
{new Date(item.createdAt).toLocaleDateString("id-ID", {
{new Date(item.publishedAt).toLocaleDateString("id-ID", {
day: "2-digit",
month: "long",
year: "numeric",