30 lines
570 B
Plaintext
30 lines
570 B
Plaintext
|
|
---
|
||
|
|
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>
|
||
|
|
)}
|
||
|
|
|