Files
profile-front/src/components/NewsSingle.astro
Profile Profile 87cdb5d2e8 delete hover cards
2026-03-10 16:39:15 +03:00

90 lines
2.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
import { stripHtml } from '@/utils/htmlhelpers';
import Author from '@components/AuthorDisplay.astro';
import Subscribe from '@components/SubscribePost.astro';
import ShareButtons from '@components/ShareButtons.astro';
interface Props {
post: any;
pageInfo?: any;
}
const { post, pageInfo } = Astro.props;
---
{post ? (
<div class="article-wrapper">
<article class="news-single">
<div class="article_info">
<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>
<h1>{post.title}</h1>
{post.secondaryTitle && <h2 class="secondary-title">{post.secondaryTitle}</h2>}
{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>
)}
{post.content && <div set:html={post.content} />}
<Subscribe />
</article>
<ShareButtons url={post.uri} title={post.title} />
</div>
) : (
<div>Новость не найдена</div>
)}
{/* Блок с тегами */}
{post.tags?.nodes && post.tags.nodes.length > 0 && (
<div class="tags-block">
<span class="tags-label">Метки:</span>
<div class="tags-list">
{post.tags.nodes.map((tag) => (
<a
href={`/tag/${encodeURIComponent(tag.name.replace(/\s+/g, '+'))}/`}
class="tag-link"
key={tag.id}
>
{tag.name}
</a>
))}
</div>
</div>
)}