From 54ec09afe08b8dbb6323b176db114b98d17ad6c2 Mon Sep 17 00:00:00 2001 From: ariari04 Date: Tue, 3 Sep 2024 11:35:13 +0600 Subject: [PATCH] Fix description for news --- src/app/[locale]/news/[id]/page.tsx | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/app/[locale]/news/[id]/page.tsx b/src/app/[locale]/news/[id]/page.tsx index 249bdd2..25a749b 100644 --- a/src/app/[locale]/news/[id]/page.tsx +++ b/src/app/[locale]/news/[id]/page.tsx @@ -14,9 +14,7 @@ export async function generateMetadata({ }: { params: { id: string }; }): Promise { - const response = await apiInstance.get( - `/news/${params.id}/` - ); + const response = await apiInstance.get(`/news/${params.id}/`); return { title: response.data.title, @@ -28,6 +26,9 @@ export async function generateMetadata({ }, }; } +const formatDescription = (text: string) => { + return text.replace(/(\r\n|\n|\r)/g, "
"); +}; const NewsDetails = async ({ params, @@ -35,9 +36,7 @@ const NewsDetails = async ({ params: { id: string; новость: string }; }) => { const getNewsById = async () => { - const response = await apiInstance.get( - `/news/${params.id}/` - ); + const response = await apiInstance.get(`/news/${params.id}/`); return response.data; }; @@ -71,9 +70,9 @@ const NewsDetails = async ({ Calendar Icon

{months[data.created_at.slice(5, 7)]}{" "} - {data.created_at.slice(5, 7).slice(0, 1) === "0" - ? data.created_at.slice(6, 7) - : data.created_at.slice(5, 7)} + {data.created_at.slice(8, 10) === "0" + ? data.created_at.slice(9, 10) + : data.created_at.slice(8, 10)} , {data.created_at.slice(0, 4)}

@@ -87,7 +86,12 @@ const NewsDetails = async ({

{data.title}

-

{data.description}

+