Files
profile-front/src/templates/NewsSingle.astro

30 lines
570 B
Plaintext
Raw Normal View History

2026-01-19 16:28:24 +03:00
---
import { getPostById } from '@lib/api/all';
interface Props {
postId?: number;
pageInfo?: any;
}
const { postId, pageInfo } = Astro.props;
let post = null;
if (postId) {
const response = await getPostById(postId);
post = response?.post;
}
---
{post ? (
<article class="news-single">
<h1>{post.title}</h1>
<div class="meta">
{post.date && <time>{new Date(post.date).toLocaleDateString('ru-RU')}</time>}
</div>
{post.content && <div set:html={post.content} />}
</article>
) : (
<div>Новость не найдена</div>
)}