94 lines
2.8 KiB
Plaintext
94 lines
2.8 KiB
Plaintext
---
|
||
import { stripHtml } from '@/utils/htmlhelpers';
|
||
import Author from '@components/AuthorDisplay.astro';
|
||
import Subscribe from '@components/SubscribePost.astro';
|
||
import ShareButtons from '@components/ShareButtons.astro';
|
||
import EmbeddedPost from '@components/EmbeddedPost.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 class="article-content" set:html={post.content} />}
|
||
|
||
<Subscribe />
|
||
</article>
|
||
|
||
<ShareButtons url={post.uri} title={post.title} />
|
||
<EmbeddedPost />
|
||
|
||
</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.slug.replace(/\s+/g, '+'))}/`}
|
||
class="tag-link"
|
||
key={tag.id}
|
||
>
|
||
{tag.name}
|
||
</a>
|
||
))}
|
||
</div>
|
||
</div>
|
||
)}
|
||
|