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

90 lines
2.6 KiB
Plaintext
Raw Normal View History

2026-01-19 16:28:24 +03:00
---
2026-02-18 01:02:01 +03:00
import { stripHtml } from '@/utils/htmlhelpers';
import Author from '@components/AuthorDisplay.astro';
import Subscribe from '@components/SubscribePost.astro';
import ShareButtons from '@components/ShareButtons.astro';
2026-01-19 16:28:24 +03:00
2026-02-27 00:12:33 +03:00
2026-01-19 16:28:24 +03:00
interface Props {
2026-01-22 00:00:07 +03:00
post: any;
2026-01-19 16:28:24 +03:00
pageInfo?: any;
}
2026-01-22 00:00:07 +03:00
const { post, pageInfo } = Astro.props;
2026-01-19 16:28:24 +03:00
---
{post ? (
2026-02-18 01:02:01 +03:00
<div class="article-wrapper">
<article class="news-single">
2026-02-18 23:33:35 +03:00
2026-02-18 01:02:01 +03:00
<div class="article_info">
2026-03-02 00:39:07 +03:00
<div class="publication__data">
{post.date && (
<time datetime={new Date(post.date).toISOString()}>
{new Date(post.date).toLocaleDateString('ru-RU')}
</time>
)}
</div>
<span class="divider" aria-hidden="true"></span>
<div class="publication__author">
<Author post={post} separator=", " />
</div>
</div>
2026-02-18 23:33:35 +03:00
2026-02-18 01:02:01 +03:00
<h1>{post.title}</h1>
2026-02-18 23:33:35 +03:00
{post.secondaryTitle && <h2 class="secondary-title">{post.secondaryTitle}</h2>}
2026-02-18 01:02:01 +03:00
{post.featuredImage?.node?.sourceUrl && (
<figure class="featured-image">
<img
src={post.featuredImage.node.sourceUrl}
alt={post.featuredImage.node.altText || post.title}
width={post.featuredImage.node.mediaDetails?.width || 1200}
height={post.featuredImage.node.mediaDetails?.height || 675}
loading="eager"
class="post-image"
/>
{(post.featuredImage.node.description || post.featuredImage.node.caption) && (
<figcaption class="image-caption">
{post.featuredImage.node.description && (
<p>{stripHtml(post.featuredImage.node.description)}</p>
)}
{post.featuredImage.node.caption && (
<span>©{stripHtml(post.featuredImage.node.caption)}</span>
)}
</figcaption>
)}
</figure>
)}
2026-03-02 00:39:07 +03:00
2026-02-18 01:02:01 +03:00
{post.content && <div set:html={post.content} />}
2026-02-18 23:33:35 +03:00
<Subscribe />
2026-02-18 01:02:01 +03:00
</article>
<ShareButtons url={post.uri} title={post.title} />
</div>
2026-01-19 16:28:24 +03:00
) : (
<div>Новость не найдена</div>
)}
2026-03-02 00:39:07 +03:00
{/* Блок с тегами */}
{post.tags?.nodes && post.tags.nodes.length > 0 && (
<div class="tags-block">
2026-03-02 23:10:31 +03:00
<span class="tags-label">Метки:</span>
2026-03-02 00:39:07 +03:00
<div class="tags-list">
{post.tags.nodes.map((tag) => (
<a
2026-03-13 20:22:35 +03:00
href={`/tag/${encodeURIComponent(tag.slug.replace(/\s+/g, '+'))}/`}
2026-03-02 00:39:07 +03:00
class="tag-link"
key={tag.id}
>
{tag.name}
</a>
))}
</div>
</div>
)}
2026-02-18 23:33:35 +03:00