Созданы хлебные крошки

This commit is contained in:
Web-serfer 2026-04-07 22:53:04 +05:00
parent 7d4289bd9e
commit 70e75dc11b
16 changed files with 350 additions and 44 deletions

View file

@ -0,0 +1,97 @@
---
export interface BreadcrumbItem {
label: string;
href?: string;
}
export interface Props {
items: BreadcrumbItem[];
}
const { items } = Astro.props;
---
<nav class="breadcrumbs" aria-label="Навигация по странице">
<div class="site-container">
<ol class="breadcrumbs-list">
{items.map((item, index) => (
<li class="breadcrumb-item">
{item.href && index < items.length - 1 ? (
<a href={item.href} class="breadcrumb-link">{item.label}</a>
) : (
<span class="breadcrumb-current">{item.label}</span>
)}
{index < items.length - 1 && (
<svg class="breadcrumb-separator" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="m9 18 6-6-6-6"/>
</svg>
)}
</li>
))}
</ol>
</div>
</nav>
<style>
.breadcrumbs {
padding: 0.75rem 0 0.75rem;
background: transparent;
}
.breadcrumbs-list {
display: flex;
align-items: center;
gap: 0.5rem;
list-style: none;
margin: 0;
padding: 0;
}
.breadcrumb-item {
display: flex;
align-items: center;
gap: 0.5rem;
}
.breadcrumb-link {
color: #64748b;
text-decoration: none;
font-size: 0.875rem;
font-weight: 500;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
padding: 0.25rem 0;
}
.breadcrumb-link:hover {
color: #d4af37;
}
.breadcrumb-current {
color: #1e293b;
font-size: 0.875rem;
font-weight: 600;
}
.breadcrumb-separator {
width: 1rem;
height: 1rem;
color: #94a3b8;
flex-shrink: 0;
}
@media (max-width: 640px) {
.breadcrumbs {
padding: 0.75rem 0 0.5rem;
}
.breadcrumb-link,
.breadcrumb-current {
font-size: 0.8rem;
}
.breadcrumb-separator {
width: 0.875rem;
height: 0.875rem;
}
}
</style>

View file

@ -2,9 +2,10 @@
export interface Props {
categories: string[];
activeCategory?: string;
currentPage?: number;
}
const { categories, activeCategory = 'Все' } = Astro.props;
const { categories, activeCategory = 'Все', currentPage = 1 } = Astro.props;
---
<div class="blog-categories">
@ -12,12 +13,13 @@ const { categories, activeCategory = 'Все' } = Astro.props;
<div class="categories-inner animate-on-scroll" data-animation="fade-up">
<div class="categories-wrapper">
{categories.map((cat) => (
<button
<a
href={cat === 'Все' ? '/blog' : `/blog/category/${cat.toLowerCase()}`}
class={`category-btn ${cat === activeCategory ? 'active' : ''}`}
data-category={cat}
>
{cat}
</button>
</a>
))}
</div>
@ -82,12 +84,15 @@ const { categories, activeCategory = 'Все' } = Astro.props;
cursor: pointer;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
white-space: nowrap;
text-decoration: none;
display: inline-block;
}
.category-btn:hover {
border-color: #d4af37;
color: #d4af37;
transform: translateY(-2px);
text-decoration: none;
}
.category-btn.active {
@ -95,6 +100,7 @@ const { categories, activeCategory = 'Все' } = Astro.props;
border-color: #d4af37;
color: #1e293b;
box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
text-decoration: none;
}
/* Анимации */
@ -144,42 +150,7 @@ const { categories, activeCategory = 'Все' } = Astro.props;
document.addEventListener('astro:page-load', initFilter);
function initFilter() {
const buttons = document.querySelectorAll('.category-btn');
const cards = document.querySelectorAll('.blog-card-wrapper');
buttons.forEach(btn => {
btn.addEventListener('click', () => {
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');
if (category === 'Все' || cardCategory === category) {
card.style.display = '';
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
requestAnimationFrame(() => {
card.style.transition = 'opacity 0.4s ease, transform 0.4s ease';
card.style.opacity = '1';
card.style.transform = 'translateY(0)';
});
} else {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
setTimeout(() => {
card.style.display = 'none';
}, 300);
}
});
});
});
const links = document.querySelectorAll('.category-btn');
// Открытие поиска
const searchBtn = document.getElementById('search-icon-btn');