Files
nextjs-style-guide/.vitepress/config.ts
S.Gromov 74cbd43a23
All checks were successful
CI/CD Pipeline / docker (push) Successful in 46s
CI/CD Pipeline / deploy (push) Successful in 7s
feat: чистые URL без .html
- VitePress: включён cleanUrls
- Caddyfile: try_files пробует .html для запросов без расширения
- Caddyfile: 301-редирект /foo.html → /foo для совместимости
- sitemap.xml: канонические URL без .html
2026-04-27 10:12:30 +03:00

163 lines
7.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineConfig } from 'vitepress';
const sidebar = [
{
text: 'Главная',
link: '/docs/',
},
{
text: 'Workflow',
link: '/docs/workflow',
},
{
text: 'Базовые правила',
items: [
{ text: 'Технологии и библиотеки', link: '/docs/basics/tech-stack' },
{ text: 'Именование', link: '/docs/basics/naming' },
{
text: 'Архитектура',
collapsed: true,
items: [
{ text: 'Обзор', link: '/docs/basics/architecture/' },
{ text: 'Слои', link: '/docs/basics/architecture/reference/layers' },
{ text: 'Модули', link: '/docs/basics/architecture/reference/modules' },
{ text: 'Сегменты', link: '/docs/basics/architecture/reference/segments' },
],
},
{ text: 'Стиль кода', link: '/docs/basics/code-style' },
{ text: 'Документирование', link: '/docs/basics/documentation' },
{ text: 'Типизация', link: '/docs/basics/typing' },
],
},
{
text: 'Установка и настройка',
items: [
{
text: 'Создание проекта',
collapsed: true,
items: [
{ text: 'Из шаблона', link: '/docs/setup/project-from-template' },
{ text: 'Вручную', link: '/docs/setup/project-manual' },
],
},
{ text: 'Next.js', link: '/docs/setup/nextjs' },
{ text: 'Алиасы', link: '/docs/setup/aliases' },
{ text: 'Biome', link: '/docs/setup/biome' },
{ text: 'Стили', link: '/docs/setup/styles' },
{ text: 'PostCSS', link: '/docs/setup/postcss' },
{ text: 'SVG-спрайты', link: '/docs/setup/svg-sprites' },
{ text: 'Шаблоны генерации', link: '/docs/setup/templates' },
{ text: 'VS Code', link: '/docs/setup/vscode' },
],
},
{
text: 'Использование',
items: [
{ text: 'Структура проекта', link: '/docs/usage/project-structure' },
{ text: 'Компоненты', link: '/docs/usage/components' },
{ text: 'Страницы (App Router)', link: '/docs/usage/page-level' },
{ text: 'Шаблоны и генерация кода', link: '/docs/usage/templates-generation' },
{ text: 'Стили', link: '/docs/usage/styles' },
{ text: 'Изображения', link: '/docs/usage/images-sprites' },
{ text: 'SVG-спрайты', link: '/docs/usage/svg-sprites' },
{ text: 'Видео', link: '/docs/usage/video' },
{
text: 'Данные',
collapsed: true,
items: [
{ text: 'Введение', link: '/docs/usage/data/' },
{
text: 'REST',
collapsed: true,
items: [
{
text: 'Клиенты',
collapsed: true,
items: [
{ text: 'Автоматическая генерация', link: '/docs/usage/data/rest/clients/auto' },
{ text: 'Ручная генерация', link: '/docs/usage/data/rest/clients/manual' },
],
},
{
text: 'Получение данных',
collapsed: true,
items: [
{ text: 'Серверные компоненты', link: '/docs/usage/data/rest/fetching/server' },
{ text: 'Клиентские компоненты', link: '/docs/usage/data/rest/fetching/client' },
],
},
],
},
{ text: 'Realtime', link: '/docs/usage/data/realtime' },
],
},
{ text: 'Stores', link: '/docs/usage/stores' },
{ text: 'Хуки', link: '/docs/usage/hooks' },
{ text: 'Шрифты', link: '/docs/usage/fonts' },
{ text: 'Локализация', link: '/docs/usage/localization' },
],
},
];
/**
* Vite-плагин: отдаёт `.txt` и `.md` с явной кодировкой UTF-8.
* Без этого браузер декодирует как ISO-8859-1 и кириллица ломается.
*/
const utf8TextPlugin = {
name: 'utf8-text-files',
configureServer(server: any) {
server.middlewares.use((req: any, res: any, next: any) => {
const url: string = req.url || '';
if (url.endsWith('.txt') || url.endsWith('.md')) {
res.setHeader('Content-Type', 'text/plain; charset=utf-8');
}
next();
});
},
};
export default defineConfig({
srcDir: 'docs',
// `docs/public/` содержит сгенерированные `.md`-копии и `llms.txt` для LLM
// (попадают в корень `dist/` как статика). Исключаем из сканирования
// страниц, иначе VitePress рендерит их как HTML-страницы.
srcExclude: ['public/**'],
lang: 'ru-RU',
title: 'NextJS Style Guide',
description: 'Стандарты разработки на Next.js + TypeScript с архитектурой SLM',
// Чистые URL без `.html` — канон для индексации.
// Серверная поддержка реализована в Caddyfile (try_files + редирект).
cleanUrls: true,
// Дублируем указатель на llms.txt в <head> — для агентов,
// которые читают HTML, но не парсят полный DOM/href.
head: [
['link', { rel: 'alternate', type: 'text/plain', href: '/llms.txt', title: 'llms.txt' }],
['link', { rel: 'alternate', type: 'text/plain', href: '/llms-full.txt', title: 'llms-full.txt' }],
],
vite: {
plugins: [utf8TextPlugin],
define: {
__BUILD_VERSION__: JSON.stringify(process.env.BUILD_VERSION || 'dev'),
},
},
themeConfig: {
sidebar,
socialLinks: [
{ icon: 'github', link: 'https://gromlab.ru/docs/nextjs-style-guide' },
],
},
// Расширенный блок описания для llms.txt — даёт LLM полный
// технический контекст: стек, методология, охват тем.
// Используется в generate-llms.ts.
llmsBlockquote:
'Стандарты разработки frontend-приложений на Next.js (App Router) + TypeScript + React с архитектурой SLM (Scoped Layered Module Design — модульная архитектура со слоями ответственности, где каждый модуль содержит всё необходимое: компоненты, хуки, сторы, типы, стили).',
llmsContext:
'Стек: React, TypeScript, Next.js App Router, Mantine UI, SWR, Zustand, i18next, PostCSS Modules, Vitest, clsx.\n\nДокументация покрывает архитектуру SLM (слои, модули, сегменты, направление зависимостей, публичный API), правила оформления кода (именование, форматирование, импорты, типизация, JSDoc), реализацию компонентов и хуков, работу с App Router, кодогенерацию из шаблонов, стилизацию (Mobile First, токены), работу с API и сокетами, управление состоянием через Zustand, локализацию, ассеты (шрифты, изображения, SVG-спрайты) и настройку VS Code.',
} as any);