fix-index

This commit is contained in:
Rusovich Violetta
2025-12-25 16:16:46 +03:00
parent 7fd1755a7d
commit abdc7bd70e
6 changed files with 38 additions and 17 deletions
+4 -1
View File
@@ -3,6 +3,7 @@ import { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'
import { overrideComponents } from './override-components'
import { autoSectionLinksPlugin } from './plugins/auto-section-links'
import { resolve } from 'path'
import { SidebarItem } from './plugins/utils/types'
const gitlab = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
@@ -41,6 +42,7 @@ const gitlab = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
const new_version = process.env?.VITE_NEW_VERSION;
console.log({ base: typeof new_version !== 'undefined' ? '/' : '/docs/' })
const sidebarConfig = {
'/platform/': [
{
@@ -181,7 +183,7 @@ const sidebarConfig = {
{ text: 'Квоты и лимиты', link: '/compute/compute-quatos.md' },
]
},
{text: 'Быстрый старт', link: '/compute/compute-getting-started.md'},
{text: 'Быстрый старт', link: '/compute/compute-getting-started.md', excludeFromIndex: true },
{ text: 'Виртуальные машины', link: '/compute/compute-how-to/compute-index.md',
collapsed: true,
items: [
@@ -207,6 +209,7 @@ const sidebarConfig = {
{ text: 'Настройка site-to-site VPN с помощью VyOS', link: '/compute/compute-how-to/compute-network/compute-vpn-vyos.md' },
{ text: 'Подключение ВМ закрытого контура к интернету', link: '/compute/compute-how-to/compute-network/compute-network-inside.md' },
],
excludeFromIndex: true,
},
],
'/admin/': [
+23 -11
View File
@@ -17,7 +17,7 @@ export const parseFrontmatter = (content: string) => {
const lines = frontmatterText.split('\n')
let currentKey: string | undefined
let currentValue: SectionLinkListItem[] = []
let currentItem: Partial<SectionLinkListItem> | undefined
let currentItem: Record<string, string> | undefined
let inArray = false
for (const line of lines) {
@@ -51,8 +51,15 @@ export const parseFrontmatter = (content: string) => {
currentValue = []
}
if (currentItem && !currentValue.includes(currentItem as SectionLinkListItem)) {
currentValue.push(currentItem as SectionLinkListItem)
if (currentItem && currentItem.title && currentItem.link !== undefined) {
const link: SectionLinkListItem = {
title: currentItem.title,
link: currentItem.link,
description: currentItem.description
}
if (!currentValue.some(item => item.link === link.link)) {
currentValue.push(link)
}
}
const itemText = trimmed.slice(2).trim()
@@ -63,9 +70,8 @@ export const parseFrontmatter = (content: string) => {
const colonMatch = part.match(/^(\w+):\s*(.+)$/)
if (colonMatch) {
const [, key, value] = colonMatch
const sectionKey = key as keyof SectionLinkListItem
if (SECTION_LINK_KEYS.includes(sectionKey)) {
currentItem[sectionKey] = value.replace(/^["']|["']$/g, '')
if (SECTION_LINK_KEYS.includes(key as typeof SECTION_LINK_KEYS[number])) {
currentItem[key] = value.replace(/^["']|["']$/g, '')
}
}
}
@@ -77,17 +83,23 @@ export const parseFrontmatter = (content: string) => {
if (colonIndex !== -1) {
const key = trimmed.substring(0, colonIndex).trim()
const value = trimmed.substring(colonIndex + 1).trim()
const sectionKey = key as keyof SectionLinkListItem
if (SECTION_LINK_KEYS.includes(sectionKey)) {
currentItem[sectionKey] = value === '' ? '' : value.replace(/^["']|["']$/g, '')
if (SECTION_LINK_KEYS.includes(key as typeof SECTION_LINK_KEYS[number])) {
currentItem[key] = value === '' ? '' : value.replace(/^["']|["']$/g, '')
}
}
}
}
}
if (currentItem && inArray && !currentValue.includes(currentItem as SectionLinkListItem)) {
currentValue.push(currentItem as SectionLinkListItem)
if (currentItem && inArray && currentItem.title && currentItem.link !== undefined) {
const link: SectionLinkListItem = {
title: currentItem.title,
link: currentItem.link,
description: currentItem.description
}
if (!currentValue.some(item => item.link === link.link)) {
currentValue.push(link)
}
}
if (inArray && currentKey) {
frontmatter[currentKey] = currentValue
+8
View File
@@ -59,6 +59,10 @@ export const extractTopLevelLinks = (
const normalizedCurrentPath = normalizeLink(currentIndexPath)
for (const item of items) {
if ('excludeFromIndex' in item && item.excludeFromIndex) {
continue
}
if (item.link) {
const normalizedItemPath = normalizeLink(item.link)
if (normalizedItemPath === normalizedCurrentPath) {
@@ -90,6 +94,10 @@ const findItemsRecursive = (
if (normalizedItemPath === normalizedPagePath && item.items && Array.isArray(item.items) && item.items.length > 0) {
for (const subItem of item.items) {
if ('excludeFromIndex' in subItem && subItem.excludeFromIndex) {
continue
}
if (subItem.link) {
links.push({
title: subItem.text || '',
+1 -1
View File
@@ -8,5 +8,5 @@ export type SidebarItem = {
export type Frontmatter = {
section_links?: SectionLinkListItem[]
[key: string]: any
[key: string]: string | number | boolean | string[] | SectionLinkListItem[] | undefined
}
@@ -2,6 +2,8 @@ export type SectionLinkListItem = {
title: string,
link: string,
description?: string
collapsed?: boolean
excludeFromIndex?: boolean
}
export type SectionLinkListProps = {
-4
View File
@@ -3,8 +3,6 @@ section_links:
- title: Обзор сервиса
link: /compute/compute-overview-index.md
description: Обзор сервиса, решаемые задачи, характеристики оборудования
- title: Быстрый старт
link: /compute/compute-getting-started.md
- title: Виртуальные машины
link: /compute/compute-how-to/compute-index.md
description: Создание виртуальной машины и подключение к ней, управление виртуальной машиной
@@ -17,8 +15,6 @@ section_links:
- title: Группы размещения
link: /compute/compute-how-to/compute-affinity.md
description: Создание правил размещения виртуальных машин на физических хостах, управление группами размещения
- title: Сети
link: /compute/compute-how-to/compute-network/compute-network-index.md
---
# Виртуальные машины