diff --git a/app/detail/[slug]/page.tsx b/app/detail/[slug]/page.tsx new file mode 100644 index 0000000..69af48a --- /dev/null +++ b/app/detail/[slug]/page.tsx @@ -0,0 +1,31 @@ +import DetailContent from "@/components/details/details-content"; +import Navbar from "@/components/landing-page/navbar"; + +import Image from "next/image"; +import { Footer } from "react-day-picker"; + +export default function Slug() { + return ( +
+
+ Background +
+ +
+ +
+ +
+ +
+
+ ); +} diff --git a/app/detail/slug/[slug]/page.tsx b/app/detail/slug/[slug]/page.tsx new file mode 100644 index 0000000..69af48a --- /dev/null +++ b/app/detail/slug/[slug]/page.tsx @@ -0,0 +1,31 @@ +import DetailContent from "@/components/details/details-content"; +import Navbar from "@/components/landing-page/navbar"; + +import Image from "next/image"; +import { Footer } from "react-day-picker"; + +export default function Slug() { + return ( +
+
+ Background +
+ +
+ +
+ +
+ +
+
+ ); +} diff --git a/components/details/details-content.tsx b/components/details/details-content.tsx index de2ba5c..724f846 100644 --- a/components/details/details-content.tsx +++ b/components/details/details-content.tsx @@ -3,7 +3,11 @@ import Image from "next/image"; import Author from "../landing-page/author"; import { useEffect, useState } from "react"; import Link from "next/link"; -import { getArticleById, getListArticle } from "@/service/article"; +import { + getArticleById, + getArticleBySlug, + getListArticle, +} from "@/service/article"; import { close, error, loading } from "@/config/swal"; import { useParams, usePathname } from "next/navigation"; import { Link2, MailIcon } from "lucide-react"; @@ -21,6 +25,7 @@ type TabKey = "trending" | "comments" | "latest"; type Article = { id: number; + slug: string; title: string; description: string; htmlDescription: string; @@ -56,6 +61,7 @@ type Advertise = { export default function DetailContent() { const params = useParams(); const id = params?.id; + const slug = params?.slug; const pathname = usePathname(); const [page, setPage] = useState(1); const [totalPage, setTotalPage] = useState(1); @@ -293,7 +299,7 @@ export default function DetailContent() { async function initStateData() { loading(); - const res = await getArticleById(id); + const res = await getArticleBySlug(slug); const data = res?.data?.data; setThumbnail(data?.thumbnailUrl); @@ -372,7 +378,7 @@ export default function DetailContent() { - {new Date(articleDetail?.createdAt).toLocaleDateString( + {new Date(articleDetail?.publishedAt).toLocaleDateString( "id-ID", { day: "numeric", diff --git a/components/landing-page/header.tsx b/components/landing-page/header.tsx index 96ea7fc..2ae28a0 100644 --- a/components/landing-page/header.tsx +++ b/components/landing-page/header.tsx @@ -13,6 +13,7 @@ type Article = { categoryName: string; createdAt: string; createdByName: string; + slug: string; customCreatorName: string; thumbnailUrl: string; categories: { @@ -117,7 +118,7 @@ export default function HeroNewsSection() {
{articles.length > 0 && (
- + {articles.slice(1, 5).map((article, index) => (
- +