diff --git a/app/details/[slug]/page.tsx b/app/details/[slug]/page.tsx
new file mode 100644
index 0000000..a509a5b
--- /dev/null
+++ b/app/details/[slug]/page.tsx
@@ -0,0 +1,19 @@
+import DetailContent from "@/components/details/details-content";
+import Footer from "@/components/landing-page/footer";
+import Navbar from "@/components/landing-page/navbar";
+import Image from "next/image";
+
+export default function Slug() {
+ return (
+
+ );
+}
diff --git a/components/details/details-content.tsx b/components/details/details-content.tsx
index 9f37e2f..c1b64b5 100644
--- a/components/details/details-content.tsx
+++ b/components/details/details-content.tsx
@@ -2,7 +2,11 @@
import Image from "next/image";
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 { CommentIcon } from "../icons/sidebar-icon";
@@ -16,6 +20,7 @@ import {
} from "@/service/master-user";
import { useForm } from "react-hook-form";
import { saveActivity } from "@/service/activity-log";
+import { Badge } from "../ui/badge";
type TabKey = "trending" | "comments" | "latest";
@@ -25,6 +30,7 @@ type Article = {
description: string;
categoryName: string;
createdAt: string;
+ slug: string;
createdByName: string;
customCreatorName: string;
thumbnailUrl: string;
@@ -55,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);
@@ -253,8 +260,8 @@ export default function DetailContent() {
async function initStateData() {
loading();
- const res = await getArticleById(id);
- const data = res.data?.data;
+ const res = await getArticleBySlug(slug);
+ const data = res?.data?.data;
setThumbnail(data?.thumbnailUrl);
setDiseId(data?.aiArticleId);
@@ -533,9 +540,17 @@ export default function DetailContent() {
{articleDetail?.tags ? (
-
- {articleDetail.tags}
-
+ articleDetail.tags
+ .split(",") // pisahkan berdasarkan koma
+ .map((tag: string, index: number) => (
+
+ {tag.trim()}
+
+ ))
) : (
Tidak ada tag
)}
@@ -705,7 +720,7 @@ export default function DetailContent() {
{articles.map((article) => (
-
+
READ MORE >
@@ -130,7 +131,7 @@ export default function HeaderEkonomi() {
Recent Posts
{recentPosts.map((post, index) => (
-
+
{articles.map((article) => (
-
+
READ MORE >
@@ -129,7 +130,7 @@ export default function HeaderHealth() {
Recent Posts
{recentPosts.map((post, index) => (
-
+
{articles.map((article) => (
-
+
READ MORE >
@@ -129,7 +130,7 @@ export default function HeaderNarrative() {
Recent Posts
{recentPosts.map((post, index) => (
-
+
{
{articles.map((item) => (
-
+
{articles.map((item) => (
-
+
-
+
{/* Left Content */}
@@ -569,7 +570,7 @@ export default function News() {
{post.description.split(" ").slice(0, 50).join(" ")}
{post.description.split(" ").length > 50 && "..."}
-
+
@@ -645,7 +646,7 @@ export default function News() {
{post.description.split(" ").slice(0, 50).join(" ")}
{post.description.split(" ").length > 50 && "..."}
-
+
diff --git a/components/landing-page/travel-news.tsx b/components/landing-page/travel-news.tsx
index de0d3d7..8d3508f 100644
--- a/components/landing-page/travel-news.tsx
+++ b/components/landing-page/travel-news.tsx
@@ -13,6 +13,7 @@ type Article = {
createdAt: string;
createdByName: string;
thumbnailUrl: string;
+ slug: string;
categories: {
title: string;
}[];
@@ -119,7 +120,7 @@ const TravelNews = () => {
{
+ const copyUrlArticle = async (slug: any) => {
const url =
`${window.location.protocol}//${window.location.host}` +
- "/detail/" +
- `${id}`;
+ "/details/" +
+ `${slug}`;
try {
await navigator.clipboard.writeText(url);
successToast("Success", "Article Copy to Clipboard");
@@ -263,7 +263,9 @@ export default function ArticleTable() {
- copyUrlArticle(article.id)}>
+ copyUrlArticle(article.slug)}
+ >
Copy Url Article
diff --git a/service/article.ts b/service/article.ts
index 569cef0..4f338cd 100644
--- a/service/article.ts
+++ b/service/article.ts
@@ -106,6 +106,13 @@ export async function getArticleById(id: any) {
return await httpGet(`/articles/${id}`, headers);
}
+export async function getArticleBySlug(slug: any) {
+ const headers = {
+ "content-type": "application/json",
+ };
+ return await httpGet(`/articles/slug/${slug}`, headers);
+}
+
export async function deleteArticle(id: string) {
const headers = {
"content-type": "application/json",