diff --git a/frontend/src/components/base/CTA.astro b/frontend/src/components/base/CTA.astro index 350a1d2..4475abd 100644 --- a/frontend/src/components/base/CTA.astro +++ b/frontend/src/components/base/CTA.astro @@ -207,5 +207,5 @@ const iconPaths: Record = { }; setupAnimations(); - document.addEventListener('astro:after-swap', setupAnimations); + document.addEventListener('astro:page-load', setupAnimations); diff --git a/frontend/src/components/blog/BlogCategories.astro b/frontend/src/components/blog/BlogCategories.astro index e8119fa..8bdabfd 100644 --- a/frontend/src/components/blog/BlogCategories.astro +++ b/frontend/src/components/blog/BlogCategories.astro @@ -13,13 +13,12 @@ const { categories, activeCategory = 'Все', currentPage = 1 } = Astro.props;
{categories.map((cat) => ( - {cat} - + ))}
@@ -100,7 +99,6 @@ const { categories, activeCategory = 'Все', currentPage = 1 } = Astro.props; border-color: #d4af37; color: #1e293b; box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3); - text-decoration: none; } /* Анимации */ diff --git a/frontend/src/components/home/Reviews.astro b/frontend/src/components/home/Reviews.astro index 1ce87f9..497b0e8 100644 --- a/frontend/src/components/home/Reviews.astro +++ b/frontend/src/components/home/Reviews.astro @@ -282,7 +282,7 @@ const colors = ['bg-gradient-1', 'bg-gradient-2', 'bg-gradient-3', 'bg-gradient- setupSlider(); setupAnimations(); - document.addEventListener('astro:after-swap', () => { + document.addEventListener('astro:page-load', () => { setupSlider(); setupAnimations(); }); diff --git a/frontend/src/layouts/Layout.astro b/frontend/src/layouts/Layout.astro index 98ce1b5..ee545e9 100644 --- a/frontend/src/layouts/Layout.astro +++ b/frontend/src/layouts/Layout.astro @@ -71,11 +71,17 @@ const { title, description, canonicalLink, breadcrumbs } = Astro.props; sessionStorage.setItem('scrollPosition', String(window.scrollY)); }); - // Восстанавливаем позицию скролла после перехода + // Восстанавливаем позицию скролла после перехода с плавной анимацией document.addEventListener('astro:after-swap', () => { const savedPosition = sessionStorage.getItem('scrollPosition'); if (savedPosition) { - window.scrollTo(0, parseInt(savedPosition)); + const targetScroll = parseInt(savedPosition); + setTimeout(() => { + window.scrollTo({ + top: targetScroll, + behavior: 'auto' + }); + }, 50); sessionStorage.removeItem('scrollPosition'); } }); diff --git a/frontend/src/pages/blog/category/[category].astro b/frontend/src/pages/blog/category/[category].astro new file mode 100644 index 0000000..8c101fb --- /dev/null +++ b/frontend/src/pages/blog/category/[category].astro @@ -0,0 +1,171 @@ +--- +import Layout from '@layouts/Layout.astro'; +import { SITE_URL } from '@constants'; +import PageHero from '@components/base/PageHero.astro'; +import BlogCategories from '@components/blog/BlogCategories.astro'; +import BlogCard from '@components/blog/BlogCard.astro'; +import Pagination from '@components/base/Pagination.astro'; +import SearchModal from '@components/base/SearchModal.astro'; +import { getPosts, getAllCategories, getPostImageUrl } from '@lib/pb'; + +export const prerender = false; + +const POSTS_PER_PAGE = 6; +const categorySlug = Astro.params.category || ''; + +const categories = await getAllCategories(); +const categoryName = categories.find(c => c.toLowerCase() === categorySlug.toLowerCase()) || categorySlug; + +const { posts, total, totalPages } = await getPosts({ + category: categoryName, + page: 1, + perPage: POSTS_PER_PAGE +}); + +const formatDate = (date: string) => { + 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}`; +}; +--- + + + + + + +
+
+
+ {posts.length > 0 ? ( + posts.map((post: any) => ( +
+ +
+ )) + ) : ( +
+

Статьи по теме "{categoryName}" не найдены

+ Вернуться к списку статей +
+ )} + + {totalPages > 1 && ( + + )} +
+
+
+ + +
+ + + + \ No newline at end of file diff --git a/frontend/src/pages/blog/category/[category]/page/[page].astro b/frontend/src/pages/blog/category/[category]/page/[page].astro new file mode 100644 index 0000000..cf64a4a --- /dev/null +++ b/frontend/src/pages/blog/category/[category]/page/[page].astro @@ -0,0 +1,172 @@ +--- +import Layout from '@layouts/Layout.astro'; +import { SITE_URL } from '@constants'; +import PageHero from '@components/base/PageHero.astro'; +import BlogCategories from '@components/blog/BlogCategories.astro'; +import BlogCard from '@components/blog/BlogCard.astro'; +import Pagination from '@components/base/Pagination.astro'; +import SearchModal from '@components/base/SearchModal.astro'; +import { getPosts, getAllCategories, getPostImageUrl } from '@lib/pb'; + +export const prerender = false; + +const POSTS_PER_PAGE = 6; +const categorySlug = Astro.params.category || ''; +const currentPage = Number(Astro.params.page) || 1; + +const categories = await getAllCategories(); +const categoryName = categories.find(c => c.toLowerCase() === categorySlug.toLowerCase()) || categorySlug; + +const { posts, total, totalPages } = await getPosts({ + category: categoryName, + page: currentPage, + perPage: POSTS_PER_PAGE +}); + +const formatDate = (date: string) => { + 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}`; +}; +--- + + + + + + +
+
+
+ {posts.length > 0 ? ( + posts.map((post: any) => ( +
+ +
+ )) + ) : ( +
+

Статьи по теме "{categoryName}" не найдены

+ Вернуться к списку статей +
+ )} + + {totalPages > 1 && ( + + )} +
+
+
+ + +
+ + + + \ No newline at end of file diff --git a/frontend/src/pages/blog/index.astro b/frontend/src/pages/blog/index.astro index 2d76377..ec1f23a 100644 --- a/frontend/src/pages/blog/index.astro +++ b/frontend/src/pages/blog/index.astro @@ -183,7 +183,7 @@ const formatDate = (date: string) => { setupAnimations(); setupFilter(); - document.addEventListener('astro:after-swap', () => { + document.addEventListener('astro:page-load', () => { setupAnimations(); setupFilter(); }); diff --git a/frontend/src/pages/blog/page/[page].astro b/frontend/src/pages/blog/page/[page].astro index 57473a3..36f3e7a 100644 --- a/frontend/src/pages/blog/page/[page].astro +++ b/frontend/src/pages/blog/page/[page].astro @@ -149,5 +149,5 @@ const formatDate = (date: string) => { }; setupAnimations(); - document.addEventListener('astro:after-swap', setupAnimations); + document.addEventListener('astro:page-load', setupAnimations); \ No newline at end of file diff --git a/frontend/src/pages/contacts.astro b/frontend/src/pages/contacts.astro index 97414f3..6d4c06c 100644 --- a/frontend/src/pages/contacts.astro +++ b/frontend/src/pages/contacts.astro @@ -346,7 +346,7 @@ const isAuthorized = false; // Измените на true, чтобы увиде setupForm(); // Для поддержки Astro transitions - document.addEventListener('astro:after-swap', () => { + document.addEventListener('astro:page-load', () => { setupAnimations(); setupForm(); }); diff --git a/frontend/src/pages/documents.astro b/frontend/src/pages/documents.astro index acb4c18..3d310c1 100644 --- a/frontend/src/pages/documents.astro +++ b/frontend/src/pages/documents.astro @@ -182,7 +182,7 @@ const categories = getCategories(); setupFilter(); - document.addEventListener('astro:after-swap', () => { + document.addEventListener('astro:page-load', () => { setupFilter(); }); diff --git a/frontend/src/pages/reviews.astro b/frontend/src/pages/reviews.astro index 3850403..f35f5e2 100644 --- a/frontend/src/pages/reviews.astro +++ b/frontend/src/pages/reviews.astro @@ -197,7 +197,7 @@ import ReviewsList from '@components/reviews/ReviewsList.astro'; setupAnimations(); // Для поддержки View Transitions в Astro - document.addEventListener('astro:after-swap', () => { + document.addEventListener('astro:page-load', () => { setupAnimations(); });