forked from Transparency/kgroad-frontend2
Fix description for news
This commit is contained in:
parent
c3697c9e55
commit
54ec09afe0
@ -14,9 +14,7 @@ export async function generateMetadata({
|
||||
}: {
|
||||
params: { id: string };
|
||||
}): Promise<Metadata> {
|
||||
const response = await apiInstance.get<INews>(
|
||||
`/news/${params.id}/`
|
||||
);
|
||||
const response = await apiInstance.get<INews>(`/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, "<br />");
|
||||
};
|
||||
|
||||
const NewsDetails = async ({
|
||||
params,
|
||||
@ -35,9 +36,7 @@ const NewsDetails = async ({
|
||||
params: { id: string; новость: string };
|
||||
}) => {
|
||||
const getNewsById = async () => {
|
||||
const response = await apiInstance.get<INews>(
|
||||
`/news/${params.id}/`
|
||||
);
|
||||
const response = await apiInstance.get<INews>(`/news/${params.id}/`);
|
||||
|
||||
return response.data;
|
||||
};
|
||||
@ -71,9 +70,9 @@ const NewsDetails = async ({
|
||||
<Image src={calendar} alt="Calendar Icon" />
|
||||
<p>
|
||||
{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)}
|
||||
</p>
|
||||
</div>
|
||||
@ -87,7 +86,12 @@ const NewsDetails = async ({
|
||||
|
||||
<div className="news-details__text">
|
||||
<h3>{data.title}</h3>
|
||||
<p>{data.description}</p>
|
||||
<div
|
||||
className="news-details__description"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: formatDescription(data.description),
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ReviewSection endpoint="news" id={data.id} />
|
||||
|
Loading…
Reference in New Issue
Block a user