add new logic routes
This commit is contained in:
29
src/templates/NewsSingle.astro
Normal file
29
src/templates/NewsSingle.astro
Normal 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>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user