mirror of
https://github.com/gromlab-ru/slm-design.git
synced 2026-08-22 07:30:16 +03:00
chore: Новый черновик DRAFT, удалить старые docs-v
This commit is contained in:
@@ -1,165 +1,91 @@
|
||||
import { defineConfig } from 'vitepress'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { splitSearchSections } from './search.mts'
|
||||
import { RULE_SEARCH_OPTIONS } from '../../scripts/lib/specification.mjs'
|
||||
import { defineConfig } from 'vitepress'
|
||||
|
||||
const repositoryUrl = 'https://github.com/gromlab-ru/slm-design'
|
||||
const viteConfigPath = fileURLToPath(new URL('../vite.config.mts', import.meta.url))
|
||||
|
||||
const specificationSidebar = [
|
||||
function slugifyHeading(value: string) {
|
||||
const slug = value
|
||||
.replace(/<[^>]+>/g, '')
|
||||
.replace(/`/g, '')
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/\s+/g, '-')
|
||||
.replace(/[^\p{L}\p{N}_-]/gu, '')
|
||||
.replace(/-+/g, '-')
|
||||
|
||||
return ['app', 'compositions', 'infra', 'ui', 'shared'].includes(slug)
|
||||
? `layer-${slug}`
|
||||
: slug
|
||||
}
|
||||
|
||||
const levelOneSidebar = [
|
||||
{
|
||||
text: 'Начало',
|
||||
text: 'SLM Level 1',
|
||||
items: [
|
||||
{ text: 'Обзор спецификации', link: '/ru/specification/' },
|
||||
{ text: 'Architecture modes', link: '/ru/specification/architecture-modes' },
|
||||
{ text: 'Реестр правил', link: '/ru/specification/rules' },
|
||||
{ text: 'Обзор', link: '/level-1/' },
|
||||
{ text: 'Терминология', link: '/level-1/terminology' },
|
||||
{ text: 'Слои', link: '/level-1/layers' },
|
||||
{ text: 'Зависимости', link: '/level-1/dependencies' },
|
||||
{ text: 'Модули', link: '/level-1/modules' },
|
||||
{ text: 'Группы', link: '/level-1/groups' },
|
||||
{ text: 'Сегменты', link: '/level-1/segments' },
|
||||
{ text: 'Компоненты', link: '/level-1/components' },
|
||||
{ text: 'Вложенные модули', link: '/level-1/nested-modules' },
|
||||
{ text: 'Жизненный цикл', link: '/level-1/lifecycle' },
|
||||
{ text: 'Проверка', link: '/level-1/validation' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Base SLM',
|
||||
collapsed: false,
|
||||
text: 'Правила',
|
||||
items: [
|
||||
{
|
||||
text: 'Основы',
|
||||
items: [
|
||||
{ text: 'Основные инварианты', link: '/ru/specification/foundations' },
|
||||
{ text: 'Терминология', link: '/ru/specification/terminology' },
|
||||
{ text: 'Архитектурная модель', link: '/ru/specification/architecture-model' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Слои',
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: 'Обзор', link: '/ru/specification/layers/' },
|
||||
{ text: 'App', link: '/ru/specification/layers/app' },
|
||||
{ text: 'Compositions', link: '/ru/specification/layers/compositions' },
|
||||
{ text: 'Infra', link: '/ru/specification/layers/infra' },
|
||||
{ text: 'UI', link: '/ru/specification/layers/ui' },
|
||||
{ text: 'Shared', link: '/ru/specification/layers/shared' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Общие правила',
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: 'Модули и группы', link: '/ru/specification/modules-and-groups' },
|
||||
{ text: 'Сегменты', link: '/ru/specification/segments' },
|
||||
{ text: 'Public API и импорты', link: '/ru/specification/public-api-and-imports' },
|
||||
{ text: 'State и data', link: '/ru/specification/state-and-data' },
|
||||
{ text: 'Runtime и lifecycle', link: '/ru/specification/runtime-and-lifecycle' },
|
||||
{ text: 'Тестирование', link: '/ru/specification/testing-and-conformance' },
|
||||
{ text: 'Монорепозитории', link: '/ru/specification/monorepo' },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Overlays',
|
||||
collapsed: false,
|
||||
items: [
|
||||
{
|
||||
text: 'SLM Advanced',
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: 'Advanced overlay', link: '/ru/specification/modes/advanced/' },
|
||||
{ text: 'Domains', link: '/ru/specification/modes/advanced/domains' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'SLM Pro',
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: 'Pro overlay', link: '/ru/specification/modes/pro/' },
|
||||
{ text: 'Domains', link: '/ru/specification/modes/pro/domains/' },
|
||||
{ text: 'Business', link: '/ru/specification/modes/pro/domains/business' },
|
||||
{ text: 'Framework surface', link: '/ru/specification/modes/pro/domains/framework' },
|
||||
{ text: 'Ports и adapters', link: '/ru/specification/modes/pro/domains/ports-and-adapters' },
|
||||
{ text: 'Client и server', link: '/ru/specification/modes/pro/domains/client-and-server' },
|
||||
{ text: 'Cross-domain boundary', link: '/ru/specification/modes/pro/domains/cross-domain-boundary' },
|
||||
{ text: 'Тестирование domains', link: '/ru/specification/modes/pro/domains/testing' },
|
||||
],
|
||||
},
|
||||
{ text: 'Как устроены правила', link: '/rules/' },
|
||||
{ text: 'Реестр Level 1', link: '/rules/level-1' },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
function addRuleAnchors(md: MarkdownIt) {
|
||||
const rulePattern = /^\*\*(SLM-(?:BASE|ADV|PRO)-[A-Z][A-Z-]*-\d{3}) - (ОБЯЗАН|ЗАПРЕЩЕНО|СЛЕДУЕТ|МОЖЕТ)\.\*\*/
|
||||
const kindByKeyword: Record<string, string> = {
|
||||
ОБЯЗАН: 'required',
|
||||
ЗАПРЕЩЕНО: 'prohibited',
|
||||
СЛЕДУЕТ: 'recommended',
|
||||
МОЖЕТ: 'optional',
|
||||
}
|
||||
|
||||
md.core.ruler.after('inline', 'slm-rule-anchors', (state) => {
|
||||
for (let index = 0; index < state.tokens.length - 1; index += 1) {
|
||||
const paragraph = state.tokens[index]
|
||||
const content = state.tokens[index + 1]
|
||||
|
||||
if (paragraph.type !== 'paragraph_open' || content.type !== 'inline') continue
|
||||
|
||||
const match = content.content.match(rulePattern)
|
||||
if (!match) continue
|
||||
|
||||
paragraph.attrSet('id', match[1].toLowerCase())
|
||||
paragraph.attrJoin('class', 'slm-rule')
|
||||
paragraph.attrJoin('class', `slm-rule--${kindByKeyword[match[2]]}`)
|
||||
|
||||
const strongCloseIndex = content.children?.findIndex((token) => token.type === 'strong_close') ?? -1
|
||||
if (strongCloseIndex < 0 || !content.children) continue
|
||||
|
||||
const permalinkOpen = new state.Token('link_open', 'a', 1)
|
||||
permalinkOpen.attrSet('class', 'slm-rule__permalink')
|
||||
permalinkOpen.attrSet('href', `#${match[1].toLowerCase()}`)
|
||||
permalinkOpen.attrSet('aria-label', `Ссылка на правило ${match[1]}`)
|
||||
permalinkOpen.attrSet('title', `Ссылка на ${match[1]}`)
|
||||
|
||||
const permalinkText = new state.Token('text', '', 0)
|
||||
permalinkText.content = '#'
|
||||
|
||||
const permalinkClose = new state.Token('link_close', 'a', -1)
|
||||
content.children.splice(
|
||||
strongCloseIndex + 1,
|
||||
0,
|
||||
permalinkOpen,
|
||||
permalinkText,
|
||||
permalinkClose,
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
const rulesSidebar = [
|
||||
{
|
||||
text: 'Правила SLM',
|
||||
items: [
|
||||
{ text: 'Формат и классификация', link: '/rules/' },
|
||||
{ text: 'Правила Level 1', link: '/rules/level-1' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Документация',
|
||||
items: [
|
||||
{ text: 'Обзор Level 1', link: '/level-1/' },
|
||||
{ text: 'Проверка', link: '/level-1/validation' },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
export default defineConfig({
|
||||
srcDir: '../docs',
|
||||
srcDir: '../DRAFT',
|
||||
srcExclude: ['README.md', 'domains/**'],
|
||||
rewrites: {
|
||||
'level-1/README.md': 'level-1/index.md',
|
||||
'rules/README.md': 'rules/index.md',
|
||||
},
|
||||
title: 'SLM Design',
|
||||
description: 'Specification for explicit architecture boundaries in product applications',
|
||||
lang: 'en-US',
|
||||
description: 'Базовая архитектура фронтенд-приложений SLM Level 1',
|
||||
lang: 'ru-RU',
|
||||
base: '/slm-design/',
|
||||
cleanUrls: true,
|
||||
lastUpdated: true,
|
||||
sitemap: {
|
||||
hostname: 'https://gromlab-ru.github.io/slm-design/',
|
||||
transformItems: (items) => items.map((item) => {
|
||||
if (!item.links?.some((link) => link.url === 'ru/')) return item
|
||||
|
||||
return {
|
||||
...item,
|
||||
links: [
|
||||
{ lang: 'x-default', url: '' },
|
||||
...item.links.filter((link) => link.url !== ''),
|
||||
],
|
||||
}
|
||||
}),
|
||||
},
|
||||
head: [
|
||||
['link', { rel: 'icon', type: 'image/svg+xml', href: '/slm-design/logo.svg' }],
|
||||
['meta', { name: 'theme-color', content: '#d97706' }],
|
||||
],
|
||||
markdown: {
|
||||
config: addRuleAnchors,
|
||||
anchor: {
|
||||
slugify: slugifyHeading,
|
||||
},
|
||||
},
|
||||
vite: {
|
||||
configFile: viteConfigPath,
|
||||
@@ -167,103 +93,68 @@ export default defineConfig({
|
||||
themeConfig: {
|
||||
logo: '/logo.svg',
|
||||
siteTitle: 'SLM Design',
|
||||
i18nRouting: false,
|
||||
nav: [
|
||||
{ text: 'Русская спецификация', link: '/ru/' },
|
||||
{ text: 'English', link: '/en/' },
|
||||
{ text: 'Level 1', link: '/level-1/' },
|
||||
{ text: 'Правила', link: '/rules/level-1' },
|
||||
],
|
||||
sidebar: {
|
||||
'/level-1/': levelOneSidebar,
|
||||
'/rules/': levelOneSidebar,
|
||||
},
|
||||
socialLinks: [{ icon: 'github', link: repositoryUrl }],
|
||||
search: {
|
||||
provider: 'local',
|
||||
options: {
|
||||
detailedView: false,
|
||||
disableQueryPersistence: true,
|
||||
miniSearch: {
|
||||
searchOptions: RULE_SEARCH_OPTIONS,
|
||||
_splitIntoSections: splitSearchSections,
|
||||
},
|
||||
locales: {
|
||||
ru: {
|
||||
translations: {
|
||||
button: {
|
||||
buttonText: 'Поиск или rule ID',
|
||||
buttonAriaLabel: 'Поиск по документации или rule ID',
|
||||
},
|
||||
modal: {
|
||||
displayDetails: 'Показать подробности',
|
||||
resetButtonTitle: 'Сбросить поиск',
|
||||
backButtonTitle: 'Закрыть поиск',
|
||||
noResultsText: 'Ничего не найдено по запросу',
|
||||
footer: {
|
||||
selectText: 'выбрать',
|
||||
navigateText: 'перейти',
|
||||
closeText: 'закрыть',
|
||||
},
|
||||
},
|
||||
translations: {
|
||||
button: {
|
||||
buttonText: 'Поиск по документации',
|
||||
buttonAriaLabel: 'Поиск по документации или коду правила',
|
||||
},
|
||||
modal: {
|
||||
displayDetails: 'Показать подробности',
|
||||
resetButtonTitle: 'Сбросить поиск',
|
||||
backButtonTitle: 'Закрыть поиск',
|
||||
noResultsText: 'Ничего не найдено',
|
||||
footer: {
|
||||
selectText: 'выбрать',
|
||||
navigateText: 'перейти',
|
||||
closeText: 'закрыть',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
locales: {
|
||||
ru: {
|
||||
label: 'Русский',
|
||||
lang: 'ru-RU',
|
||||
link: '/ru/',
|
||||
title: 'SLM Design',
|
||||
description: 'Спецификация архитектурных границ продуктовых приложений',
|
||||
themeConfig: {
|
||||
nav: [
|
||||
{ text: 'Документация', link: '/ru/' },
|
||||
{ text: 'Спецификация', link: '/ru/specification/' },
|
||||
],
|
||||
sidebar: {
|
||||
'/ru/specification/': specificationSidebar,
|
||||
},
|
||||
outline: { level: [2, 3], label: 'На этой странице' },
|
||||
editLink: {
|
||||
pattern: `${repositoryUrl}/edit/master/docs/:path`,
|
||||
text: 'Предложить изменение',
|
||||
},
|
||||
lastUpdated: {
|
||||
text: 'Обновлено',
|
||||
formatOptions: { dateStyle: 'medium' },
|
||||
},
|
||||
docFooter: {
|
||||
prev: 'Предыдущая страница',
|
||||
next: 'Следующая страница',
|
||||
},
|
||||
darkModeSwitchLabel: 'Оформление',
|
||||
lightModeSwitchTitle: 'Светлая тема',
|
||||
darkModeSwitchTitle: 'Тёмная тема',
|
||||
sidebarMenuLabel: 'Содержание',
|
||||
returnToTopLabel: 'Наверх',
|
||||
langMenuLabel: 'Изменить язык',
|
||||
skipToContentLabel: 'Перейти к содержанию',
|
||||
footer: {
|
||||
message: 'SLM Design 2.0 Draft',
|
||||
copyright: 'Нормативная русская версия находится в статусе draft.',
|
||||
},
|
||||
},
|
||||
outline: { level: [2, 3], label: 'На этой странице' },
|
||||
notFound: {
|
||||
code: '404',
|
||||
title: 'Страница не найдена',
|
||||
quote: 'Запрошенная страница отсутствует в документации Level 1.',
|
||||
linkLabel: 'Перейти на главную',
|
||||
linkText: 'Вернуться к документации',
|
||||
},
|
||||
en: {
|
||||
label: 'English',
|
||||
lang: 'en-US',
|
||||
link: '/en/',
|
||||
title: 'SLM Design',
|
||||
description: 'English translation placeholder for the SLM Design specification',
|
||||
themeConfig: {
|
||||
nav: [
|
||||
{ text: 'English status', link: '/en/' },
|
||||
{ text: 'Russian specification', link: '/ru/specification/' },
|
||||
],
|
||||
outline: { level: [2, 3], label: 'On this page' },
|
||||
footer: {
|
||||
message: 'SLM Design 2.0 Draft',
|
||||
copyright: 'The English edition is not normative yet.',
|
||||
},
|
||||
},
|
||||
editLink: {
|
||||
pattern: `${repositoryUrl}/edit/master/DRAFT/:path`,
|
||||
text: 'Предложить изменение',
|
||||
},
|
||||
lastUpdated: {
|
||||
text: 'Обновлено',
|
||||
formatOptions: { dateStyle: 'medium' },
|
||||
},
|
||||
docFooter: {
|
||||
prev: 'Предыдущая страница',
|
||||
next: 'Следующая страница',
|
||||
},
|
||||
darkModeSwitchLabel: 'Оформление',
|
||||
lightModeSwitchTitle: 'Светлая тема',
|
||||
darkModeSwitchTitle: 'Тёмная тема',
|
||||
sidebarMenuLabel: 'Содержание',
|
||||
returnToTopLabel: 'Наверх',
|
||||
skipToContentLabel: 'Перейти к содержанию',
|
||||
footer: {
|
||||
message: 'SLM Level 1',
|
||||
copyright: 'Рабочий черновик архитектуры.',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user