add page articles

This commit is contained in:
Profile Profile
2026-03-08 16:07:43 +03:00
parent 440e3da8c7
commit 572ffd07e6
3 changed files with 150 additions and 65 deletions

View File

@@ -127,7 +127,7 @@ function shouldBeLarge(index: number): boolean {
console.log(nickname); console.log(nickname);
return ( return (
<span key={nickname || name}> <span class="author-name" key={nickname || name}>
{i > 0 && ', '} {i > 0 && ', '}
{nickname ? ( {nickname ? (
<a <a

View File

@@ -0,0 +1,32 @@
---
import MainLayout from '@layouts/MainLayout.astro';
import ContentGrid from '@components/ContentGrid.astro';
import { getLatestPosts } from '@api/posts.js';
const { posts, pageInfo } = await getLatestPosts(41); // Сразу деструктурируем
//ISR
export const prerender = false;
---
<MainLayout
title=Статьи
description= Статьи
>
<h1>Статьи</h1>
<ContentGrid
items={posts}
pageInfo={pageInfo}
type="latest"
perLoad={11}
showCount={false}
/>
</MainLayout>

View File

@@ -26,45 +26,67 @@ const posts = data.posts;
> >
{author && ( {author && (
<>
{/* Если есть bio с аватаром - полная карточка */}
{author.avatar && author.bio ? (
<div class="author-card"> <div class="author-card">
{author.avatar && (
<div class="avatar"> <div class="avatar">
<img <img
src={author.avatar} src={author.avatar}
alt={author.name} alt={author.name}
width="192" width="264"
height="192" height="264"
class="avatar" class="avatar"
/> />
</div> </div>
)}
<div class="author-info"> <div class="author-info">
{(author.firstName || author.lastName) && ( {author.name && (
<h1 class="full-name"> <h1 class="full-name">
{author.firstName} {author.lastName} {author.name}
</h1> </h1>
)} )}
{author.bio && ( <div class="bio" set:html={author.bio} />
<div class="bio">{author.bio}</div>
)}
{author.social && Object.values(author.social).some(Boolean) && ( {author.social && Object.values(author.social).some(Boolean) && (
<div class="social-links"> <div class="social-links">
{author.social.twitter && ( {author.social.twitter && <a href={author.social.twitter}>Twitter</a>}
<a href={author.social.twitter}>Twitter</a> {author.social.facebook && <a href={author.social.facebook}>Facebook</a>}
)} {author.social.instagram && <a href={author.social.instagram}>Instagram</a>}
{author.social.facebook && (
<a href={author.social.facebook}>Facebook</a>
)}
{author.social.instagram && (
<a href={author.social.instagram}>Instagram</a>
)}
</div> </div>
)} )}
</div> </div>
</div> </div>
) : /* Если есть только имя - просто h1 */
author.name && !author.bio ? (
<h1 class="full-name">
{author.name}
</h1>
) : /* Если есть bio без аватара */
author.bio && !author.avatar ? (
<div class="bio">{author.bio}</div>
) : /* Если есть аватар без bio */
author.avatar && !author.bio ? (
<div class="author-card">
<div class="avatar">
<img
src={author.avatar}
alt={author.name || ''}
width="264"
height="264"
class="avatar"
/>
</div>
{author.name && (
<h1 class="full-name">
{author.name}
</h1>
)}
</div>
) : null
</>
)} )}
<ContentGrid <ContentGrid
@@ -79,75 +101,106 @@ const posts = data.posts;
<style> <style>
p{
margin: 0 0 1.6875rem
}
.author-card { .author-card {
display: flex; display: flex;
align-items: stretch; /* Все блоки одной высоты */
min-height: 350px;
width: 100%; width: 100%;
/* Убираем min-height */
} }
.author-card .avatar { .author-card .avatar {
width: 100%; width: 300px; /* Фиксированная ширина для аватара */
flex-shrink: 0; /* Запрещаем сжиматься */
aspect-ratio: 1/1; aspect-ratio: 1/1;
object-fit: cover; display: flex;
display: block; align-items: center;
justify-content: center;
height:auto;
background: linear-gradient(to right, transparent 40%, #ececec 40%); background: linear-gradient(to right, transparent 40%, #ececec 40%);
} }
.author-card .avatar IMG{ .author-card .avatar IMG {
max-width: 300px; width: 264px;
margin: 20px auto; height: 264px;
object-fit: cover;
display: block;
margin: 0;
} }
.author-card .author-info { .author-card .author-info {
display:flex; flex: 1; /* Занимает оставшееся место */
display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
gap: 12px; gap: 12px;
background-color: #ececec; background-color: #ececec;
padding: 0 42px; padding: 30px 42px; /* Уменьшаем вертикальные отступы */
} }
.author-info h1{ .author-info h1 {
font-size: 1.5rem; font-size: 1.5rem;
margin: 0; /* Убираем отступы у заголовка */
}
.author-info .bio {
margin: 0; /* Убираем отступы у bio */
line-height: 1.5;
}
.author-info .social-links {
margin-top: 4px; /* Небольшой отступ сверху */
}
/* Для случаев когда нет bio */
.author-card:has(.author-info:only-child h1) .author-info {
padding: 20px 42px; /* Еще меньше отступы если только заголовок */
} }
@media (max-width: 769px) { @media (max-width: 769px) {
.author-card { .author-card {
flex-direction: column; flex-direction: column;
min-height: auto; /* Убираем минимальную высоту */ min-height: auto;
background-color: transparent; /* Убираем фон, перенесем на блоки */ background-color: transparent;
} }
.author-card .avatar { .author-card .avatar {
width: 100%; width: 100%;
aspect-ratio: auto; /* Убираем фиксированное соотношение */ aspect-ratio: 1/1;
height: auto; background: #ececec;
background: #ececec; /* Простой фон вместо градиента */
padding: 30px 0; /* Отступы сверху/снизу */
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: 0; /* Убираем все отступы */
} }
.author-card .avatar IMG { .author-card .avatar IMG {
width: min(300px, 80%); /* Не больше 192px, но может быть меньше */ width: 80%; /* Растягиваем на всю ширину контейнера */
aspect-ratio: 1/1; /* Соотношение сторон 1:1 (квадрат) */ height: 80%; /* Растягиваем на всю высоту контейнера */
aspect-ratio: 1/1;
object-fit: cover; object-fit: cover;
margin: 0; margin: 0;
} display: block;
}
.author-card .author-info { .author-card .author-info {
flex: none; /* Убираем flex: 1 */ flex: none;
width: 100%; width: 100%;
padding: 30px 20px; /* Уменьшаем боковые отступы */ padding: 20px 20px;
background-color: #ececec; background-color: #ececec;
gap: 12px; gap: 12px;
} }
.full-name{
text-align: center;
}
/* Дополнительно уменьшаем отступы если мало контента */
.author-card .author-info:has(h1:only-child) {
padding: 15px 20px;
}
} }
</style> </style>