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