2026-04-06 21:28:31 +05:00
|
|
|
|
---
|
|
|
|
|
|
import Layout from '@layouts/Layout.astro';
|
|
|
|
|
|
import { SITE_URL } from '@constants';
|
2026-04-08 20:15:49 +05:00
|
|
|
|
import PageHero from '@components/base/PageHero.astro';
|
2026-04-06 21:28:31 +05:00
|
|
|
|
import BlogCategories from '@components/blog/BlogCategories.astro';
|
|
|
|
|
|
import BlogCard from '@components/blog/BlogCard.astro';
|
2026-04-08 21:11:36 +05:00
|
|
|
|
import Pagination from '@components/base/Pagination.astro';
|
2026-04-07 18:53:23 +05:00
|
|
|
|
import SearchModal from '@components/base/SearchModal.astro';
|
2026-04-15 12:36:58 +05:00
|
|
|
|
import { getPosts, getAllCategories, getPostImageUrl } from '@lib/pb';
|
2026-04-07 22:53:04 +05:00
|
|
|
|
|
2026-04-28 17:36:39 +05:00
|
|
|
|
const POSTS_PER_PAGE = 6;
|
2026-04-07 22:53:04 +05:00
|
|
|
|
const currentPage = 1;
|
|
|
|
|
|
|
2026-04-15 02:12:25 +05:00
|
|
|
|
const { posts, total, totalPages } = await getPosts({ page: currentPage, perPage: POSTS_PER_PAGE });
|
|
|
|
|
|
const categories = await getAllCategories();
|
2026-04-09 22:22:55 +05:00
|
|
|
|
|
2026-04-15 02:12:25 +05:00
|
|
|
|
const formatDate = (date: string) => {
|
2026-04-28 01:58:37 +05:00
|
|
|
|
const d = new Date(date);
|
|
|
|
|
|
const day = d.getDate().toString().padStart(2, '0');
|
|
|
|
|
|
const month = (d.getMonth() + 1).toString().padStart(2, '0');
|
|
|
|
|
|
const year = new Date().getFullYear().toString().slice(-2);
|
|
|
|
|
|
return `${day}/${month}/${year}`;
|
2026-04-09 22:22:55 +05:00
|
|
|
|
};
|
2026-04-29 03:54:03 +05:00
|
|
|
|
|
|
|
|
|
|
const postsCountText = String(total);
|
2026-04-06 21:28:31 +05:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
<Layout
|
|
|
|
|
|
title="Блог — автоюрист в Сургуте"
|
|
|
|
|
|
description="Полезные статьи и советы по автоспорам, ДТП, ОСАГО, лишению прав и защите прав водителей."
|
|
|
|
|
|
canonicalLink={`${SITE_URL}/blog`}
|
2026-04-07 22:53:04 +05:00
|
|
|
|
breadcrumbs={[
|
|
|
|
|
|
{ label: "Главная", href: "/" },
|
|
|
|
|
|
{ label: "Блог" }
|
|
|
|
|
|
]}
|
2026-04-06 21:28:31 +05:00
|
|
|
|
>
|
2026-04-08 20:15:49 +05:00
|
|
|
|
<PageHero
|
|
|
|
|
|
badgeText="БЛОГ И СТАТЬИ"
|
|
|
|
|
|
titleWhite="Полезные статьи"
|
|
|
|
|
|
titleGold="для автовладельцев"
|
|
|
|
|
|
description="Разбираем сложные юридические вопросы простым языком. Советы юриста по автоспорам, ДТП, ОСАГО и защите прав водителей."
|
|
|
|
|
|
layout="with-image"
|
2026-04-08 22:54:23 +05:00
|
|
|
|
sideImage="/images/blog/blogImg.avif"
|
2026-04-08 20:15:49 +05:00
|
|
|
|
sideImageAlt="Автоюрист Сургут"
|
|
|
|
|
|
experienceBadge={{
|
2026-04-29 03:54:03 +05:00
|
|
|
|
number: postsCountText,
|
2026-04-08 20:15:49 +05:00
|
|
|
|
text: "ПОЛЕЗНЫХ СТАТЕЙ"
|
|
|
|
|
|
}}
|
2026-04-08 22:54:23 +05:00
|
|
|
|
bgImage="/images/blog/blogBg.avif"
|
2026-04-11 21:38:18 +05:00
|
|
|
|
icon="edit"
|
2026-04-08 20:15:49 +05:00
|
|
|
|
/>
|
2026-04-07 20:53:26 +05:00
|
|
|
|
|
2026-04-07 22:53:04 +05:00
|
|
|
|
<BlogCategories categories={categories} activeCategory="Все" currentPage={currentPage} />
|
2026-04-06 21:28:31 +05:00
|
|
|
|
|
|
|
|
|
|
<!-- Сетка статей -->
|
|
|
|
|
|
<section class="blog-grid-section">
|
|
|
|
|
|
<div class="site-container">
|
2026-04-07 20:53:26 +05:00
|
|
|
|
<div class="blog-grid" id="blog-grid">
|
2026-04-15 02:12:25 +05:00
|
|
|
|
{posts.map((post: any) => (
|
|
|
|
|
|
<article class="blog-card-wrapper" data-category={post.category}>
|
2026-04-07 20:53:26 +05:00
|
|
|
|
<BlogCard
|
2026-04-15 02:12:25 +05:00
|
|
|
|
title={post.title}
|
|
|
|
|
|
description={post.description}
|
|
|
|
|
|
category={post.category}
|
|
|
|
|
|
categoryColor={post.categoryColor}
|
|
|
|
|
|
date={formatDate(post.date)}
|
|
|
|
|
|
readTime={post.readTime}
|
2026-04-19 22:57:29 +05:00
|
|
|
|
readmeTime={post.readmeTime}
|
2026-04-15 12:36:58 +05:00
|
|
|
|
image={getPostImageUrl(post)}
|
2026-04-15 02:12:25 +05:00
|
|
|
|
slug={`/blog/${post.slug}`}
|
2026-04-07 20:53:26 +05:00
|
|
|
|
/>
|
|
|
|
|
|
</article>
|
2026-04-06 21:28:31 +05:00
|
|
|
|
))}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Пагинация -->
|
2026-04-08 21:11:36 +05:00
|
|
|
|
<Pagination
|
|
|
|
|
|
currentPage={currentPage}
|
|
|
|
|
|
totalPages={totalPages}
|
|
|
|
|
|
baseUrl="/blog"
|
|
|
|
|
|
/>
|
2026-04-06 21:28:31 +05:00
|
|
|
|
</div>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
2026-04-07 20:53:26 +05:00
|
|
|
|
<SearchModal />
|
|
|
|
|
|
</Layout>
|
2026-04-07 18:53:23 +05:00
|
|
|
|
|
2026-04-06 21:28:31 +05:00
|
|
|
|
<style>
|
|
|
|
|
|
.blog-grid-section {
|
2026-04-28 17:36:39 +05:00
|
|
|
|
padding: 2rem 0 0;
|
2026-04-06 21:28:31 +05:00
|
|
|
|
background: #f8fafc;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.blog-grid {
|
|
|
|
|
|
display: grid;
|
|
|
|
|
|
grid-template-columns: repeat(3, 1fr);
|
|
|
|
|
|
gap: 2rem;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-07 20:53:26 +05:00
|
|
|
|
.blog-card-wrapper {
|
2026-04-10 01:28:31 +05:00
|
|
|
|
transition: opacity 0.3s ease, transform 0.3s ease, display 0.3s ease;
|
2026-04-07 20:53:26 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-06 21:28:31 +05:00
|
|
|
|
/* ===== RESPONSIVE ===== */
|
|
|
|
|
|
@media (max-width: 1024px) {
|
|
|
|
|
|
.blog-grid {
|
|
|
|
|
|
grid-template-columns: repeat(2, 1fr);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@media (max-width: 768px) {
|
|
|
|
|
|
.blog-grid {
|
|
|
|
|
|
grid-template-columns: 1fr;
|
|
|
|
|
|
gap: 1.5rem;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.blog-cta {
|
|
|
|
|
|
padding: 3rem 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|
2026-04-08 20:15:49 +05:00
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
const setupAnimations = () => {
|
|
|
|
|
|
const observerOptions = {
|
|
|
|
|
|
root: null,
|
|
|
|
|
|
rootMargin: '0px 0px -50px 0px',
|
|
|
|
|
|
threshold: 0.1
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const observer = new IntersectionObserver((entries) => {
|
|
|
|
|
|
entries.forEach(entry => {
|
|
|
|
|
|
if (entry.isIntersecting) {
|
|
|
|
|
|
const el = entry.target as HTMLElement;
|
|
|
|
|
|
const delay = parseInt(el.dataset.delay || '0');
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
el.classList.add('is-visible');
|
|
|
|
|
|
}, delay);
|
|
|
|
|
|
|
|
|
|
|
|
observer.unobserve(el);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}, observerOptions);
|
|
|
|
|
|
|
|
|
|
|
|
document.querySelectorAll('.animate-on-scroll').forEach((el) => {
|
|
|
|
|
|
observer.observe(el);
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-04-10 01:28:31 +05:00
|
|
|
|
const setupFilter = () => {
|
|
|
|
|
|
const buttons = document.querySelectorAll('.category-btn');
|
|
|
|
|
|
const cards = document.querySelectorAll('.blog-card-wrapper');
|
|
|
|
|
|
const grid = document.getElementById('blog-grid');
|
|
|
|
|
|
|
|
|
|
|
|
buttons.forEach((btn) => {
|
|
|
|
|
|
btn.addEventListener('click', (e) => {
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
const category = btn.getAttribute('data-category');
|
|
|
|
|
|
|
|
|
|
|
|
// Обновляем активную кнопку
|
|
|
|
|
|
buttons.forEach(b => b.classList.remove('active'));
|
|
|
|
|
|
btn.classList.add('active');
|
|
|
|
|
|
|
|
|
|
|
|
// Фильтруем карточки
|
|
|
|
|
|
cards.forEach((card) => {
|
|
|
|
|
|
const cardCategory = card.getAttribute('data-category');
|
2026-04-14 23:50:27 +05:00
|
|
|
|
const el = card as HTMLElement;
|
2026-04-10 01:28:31 +05:00
|
|
|
|
if (category === 'Все' || cardCategory === category) {
|
2026-04-14 23:50:27 +05:00
|
|
|
|
el.style.display = '';
|
|
|
|
|
|
el.style.opacity = '0';
|
|
|
|
|
|
el.style.transform = 'translateY(20px)';
|
2026-04-10 01:28:31 +05:00
|
|
|
|
requestAnimationFrame(() => {
|
2026-04-14 23:50:27 +05:00
|
|
|
|
el.style.transition = 'opacity 0.4s ease, transform 0.4s ease';
|
|
|
|
|
|
el.style.opacity = '1';
|
|
|
|
|
|
el.style.transform = 'translateY(0)';
|
2026-04-10 01:28:31 +05:00
|
|
|
|
});
|
|
|
|
|
|
} else {
|
2026-04-14 23:50:27 +05:00
|
|
|
|
el.style.display = 'none';
|
2026-04-10 01:28:31 +05:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-04-08 20:15:49 +05:00
|
|
|
|
setupAnimations();
|
2026-04-10 01:28:31 +05:00
|
|
|
|
setupFilter();
|
2026-04-15 02:12:25 +05:00
|
|
|
|
</script>
|