@ampernic/vitepress-theme-alt-docs 0.1.10 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,16 +21,37 @@ export default Theme
21
21
  ### Config helpers
22
22
 
23
23
  ```ts
24
- // .vitepress/config.ts
25
- import { defineConfig } from 'vitepress'
26
- import { sharedConfig } from '@ampernic/vitepress-theme-alt-docs/config'
24
+ // .vitepress/config/index.mts
25
+ import { defineConfigWithTheme } from 'vitepress'
26
+ import { createSharedConfig } from '@ampernic/vitepress-theme-alt-docs/config'
27
+ import { ru } from './ru'
28
+
29
+ const shared = createSharedConfig({
30
+ distroName: 'alt-domain',
31
+ allDistros: ['alt-domain', 'alt-workstation', 'alt-virtualization-pve', 'group-policy'],
32
+ // Группировка дистрибутивов в подменю (необязательно):
33
+ sections: [
34
+ { name: 'Альт Виртуализация', distros: ['alt-virtualization-pve'] },
35
+ { name: 'Групповые политики', distros: ['group-policy'] },
36
+ ],
37
+ })
27
38
 
28
- export default defineConfig({
29
- ...sharedConfig,
30
- // ... специфичный для сайта конфиг
39
+ export default defineConfigWithTheme({
40
+ ...shared,
41
+ locales: { root: { label: 'Русский', ...ru } },
31
42
  })
32
43
  ```
33
44
 
45
+ #### Опции `createSharedConfig`
46
+
47
+ | Опция | Тип | Описание |
48
+ |-------|-----|----------|
49
+ | `distroName` | `string` | Slug текущего дистрибутива |
50
+ | `allDistros` | `string[]` | Полный список дистрибутивов для переключателя |
51
+ | `sections` | `SectionInfo[]` | Именованные группы дистрибутивов в переключателе продуктов |
52
+ | `hostname` | `string` | Hostname для sitemap |
53
+ | `editLinkRepo` | `string` | URL репозитория для «Предложить правки» |
54
+
34
55
  ## Компоненты
35
56
 
36
57
  | Компонент | Описание |
@@ -18,8 +18,14 @@ interface DistroInfo {
18
18
  title?: string
19
19
  }
20
20
 
21
+ interface SectionInfo {
22
+ name: string
23
+ distros: string[]
24
+ }
25
+
21
26
  declare const __VERSIONS_DATA__: {
22
27
  distros: { [distroName: string]: DistroInfo }
28
+ sections?: SectionInfo[]
23
29
  }
24
30
 
25
31
  const getSafeVersionsData = (): { distros: { [k: string]: DistroInfo } } => {
@@ -162,11 +168,22 @@ const makeProductItem = (product: string) => {
162
168
  }
163
169
 
164
170
  const menuGroupItem = computed((): DefaultTheme.NavItemWithChildren => {
165
- const regular = availableProducts.value.filter((p) => !p.endsWith('-e2k'))
166
- const e2k = availableProducts.value.filter((p) => p.endsWith('-e2k'))
171
+ const sections = versionsData.sections ?? []
172
+ const sectionedDistros = new Set(sections.flatMap((s) => s.distros))
173
+
174
+ const unsectioned = availableProducts.value.filter((p) => !sectionedDistros.has(p))
175
+ const regular = unsectioned.filter((p) => !p.endsWith('-e2k'))
176
+ const e2k = unsectioned.filter((p) => p.endsWith('-e2k'))
167
177
 
168
178
  const items: DefaultTheme.NavItemWithChildren['items'] = regular.map(makeProductItem)
169
179
 
180
+ for (const section of sections) {
181
+ const sectionDistros = section.distros.filter((d) => availableProducts.value.includes(d))
182
+ if (sectionDistros.length > 0) {
183
+ items.push({ text: section.name, items: sectionDistros.map(makeProductItem) })
184
+ }
185
+ }
186
+
170
187
  if (e2k.length > 0) {
171
188
  items.push({ text: 'Для Эльбрус', items: e2k.map(makeProductItem) })
172
189
  }
@@ -1,4 +1,6 @@
1
1
  import { DefaultTheme } from 'vitepress';
2
+ import type { SectionInfo } from '@ampernic/vitepress-plugin-alt-docs-versioning';
3
+ export type { SectionInfo };
2
4
  export interface SharedConfigOptions {
3
5
  /** Distro slug for this VitePress instance, e.g. `'alt-domain'`. */
4
6
  distroName: string;
@@ -7,6 +9,17 @@ export interface SharedConfigOptions {
7
9
  * When omitted only the current distro appears in the menu — fine for local dev.
8
10
  */
9
11
  allDistros?: string[];
12
+ /**
13
+ * Optional nav groupings for the ADProducts switcher.
14
+ * Each entry renders as a sub-menu with a display name.
15
+ *
16
+ * @example
17
+ * sections: [
18
+ * { name: 'Альт Виртуализация', distros: ['alt-virtualization-pve', 'alt-virtualisation-one'] },
19
+ * { name: 'Групповые политики', distros: ['group-policy'] },
20
+ * ]
21
+ */
22
+ sections?: SectionInfo[];
10
23
  /** Sitemap hostname, e.g. `'https://docs.altlinux.org'`. */
11
24
  hostname?: string;
12
25
  /**
@@ -49,7 +49,8 @@ function createSharedConfig(options) {
49
49
  },
50
50
  plugins: [...pagefind.vite.plugins, (0, _vitepressPluginAltDocsVersioning.VersioningPlugin)({
51
51
  distroName: options.distroName,
52
- allDistros: options.allDistros
52
+ allDistros: options.allDistros,
53
+ sections: options.sections
53
54
  })]
54
55
  },
55
56
  srcDir: "docs",
@@ -52,7 +52,8 @@ export function createSharedConfig(options) {
52
52
  ...pagefind.vite.plugins,
53
53
  VersioningPlugin({
54
54
  distroName: options.distroName,
55
- allDistros: options.allDistros
55
+ allDistros: options.allDistros,
56
+ sections: options.sections
56
57
  })
57
58
  ]
58
59
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampernic/vitepress-theme-alt-docs",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Shared VitePress theme for ALT Linux documentation",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "author": "Ampernic",
@@ -33,10 +33,10 @@
33
33
  "@nolebase/vitepress-plugin-enhanced-readabilities": "^2.14.0",
34
34
  "markdown-it-kbd": "^1.0.0",
35
35
  "vitepress-plugin-tabs": "^0.6.0",
36
- "@ampernic/vitepress-plugin-alt-docs-versioning": "0.1.2",
37
- "@ampernic/vitepress-plugin-cross-site-router": "0.1.2",
36
+ "@ampernic/vitepress-plugin-alt-docs-versioning": "0.1.3",
38
37
  "@ampernic/vitepress-plugin-html-image": "0.1.2",
39
- "@ampernic/vitepress-plugin-pagefind": "0.1.8"
38
+ "@ampernic/vitepress-plugin-pagefind": "0.1.8",
39
+ "@ampernic/vitepress-plugin-cross-site-router": "0.1.2"
40
40
  },
41
41
  "devDependencies": {
42
42
  "builtin-modules": "^3.3.0",