/
AlexandrNarbaev
/
ThePath
Обзор
Документация
Войти
/
AlexandrNarbaev
/
ThePath
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
web/src/components/module/TableOfContents.astro
47 строк
1 KB
AlexandrNarbaev
fix(i18n): TableOfContents uses t() instead of hardcoded Russian
04 июн 2026, 23:27
04 июн 2026, 23:27
f5960de
Код
Авторство
О чём код?
--- import { t, type Lang } from '../../i18n/ui'; interface Heading { depth: number; text: string; slug: string; } const { headings = [], lang = 'ru' } = Astro.props as { headings?: Heading[]; lang?: Lang }; if (headings.length === 0) return null; --- <nav class="toc" aria-label="Table of contents"> <details open> <summary class="toc-title">{t('toc.title', lang)}</summary> <ul class="toc-list"> {headings.map((h) => ( <li class={`toc-item toc-depth-${h.depth}`}> <a href={`#${h.slug}`}>{h.text}</a> </li> ))} </ul> </details> </nav> <style> .toc { background: var(--color-bg-secondary); border: 1px solid var(--color-border); border-radius: 10px; padding: 1rem 1.25rem; margin-bottom: 2rem; font-size: 0.9rem; } .toc-title { font-weight: 600; cursor: pointer; user-select: none; color: var(--color-text-primary); font-size: 0.95rem; } .toc-list { list-style: none; padding: 0; margin: 0.75rem 0 0; } .toc-item { margin-bottom: 0.25rem; line-height: 1.4; } .toc-item a { color: var(--color-text-secondary); text-decoration: none; transition: color 0.15s; } .toc-item a:hover { color: var(--color-accent); } .toc-depth-2 { padding-left: 0; } .toc-depth-3 { padding-left: 1.25rem; font-size: 0.85rem; } </style>