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

153 lines
3.1 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-02-18 23:33:35 +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 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>
)}
{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} />
2026-02-18 23:33:35 +03:00
2026-02-18 01:02:01 +03:00
</div>
2026-01-19 16:28:24 +03:00
) : (
<div>Новость не найдена</div>
)}
2026-02-18 01:02:01 +03:00
<style>
2026-02-18 23:33:35 +03:00
2026-02-18 01:02:01 +03:00
.article-wrapper {
position: relative;
max-width: 75%;
padding-bottom: 2rem;
}
.news-single h1{
font-size: 2.375rem;
line-height: 1.2;
margin: 0 0 0.625rem;
}
2026-02-18 23:33:35 +03:00
.news-single h2{
font-size: 1.5rem;
line-height: 1.1;
margin: 2.0625rem 0 .375rem;
}
.news-single :global(p a) {
color: #0d6efd;
2026-02-18 01:02:01 +03:00
}
2026-02-18 23:33:35 +03:00
.article_info {
2026-02-18 01:02:01 +03:00
display: flex;
2026-02-18 23:33:35 +03:00
align-items: center;
gap: .475rem; /* одинаковое расстояние с обеих сторон от черты */
margin-top: 1.9375rem;
margin-bottom: .9375rem;
font-size: 0.875rem;
color: #666;
2026-02-18 01:02:01 +03:00
}
2026-02-18 23:33:35 +03:00
.divider {
display: block;
width: 1px;
height: 12px;
background-color: #999;
flex-shrink: 0;
2026-02-18 01:02:01 +03:00
}
2026-02-18 23:33:35 +03:00
.publication__author :global(a){
text-decoration: underline;
}
2026-02-18 01:02:01 +03:00
.featured-image {
margin: 1.5rem 0;
width: 100%;
}
.post-image {
width: 100%;
height: auto;
display: block;
border-radius: 8px;
object-fit: cover;
}
.image-caption {
font-size: 0.875rem;
color: #666;
margin-top: 0.5rem;
text-align: left;
}
.image-caption p {
margin: 0 0 0.25rem 0;
}
.image-caption span {
font-style: italic;
white-space: nowrap;
}
</style>