add new logic routes

This commit is contained in:
Profile Profile
2026-01-19 16:28:24 +03:00
parent a62ee9c278
commit c5b00af520
4 changed files with 136 additions and 22 deletions

View File

@@ -0,0 +1,29 @@
---
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>
)}