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

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.
@@ -1,25 +1,17 @@
1
1
  <template>
2
- <div v-if="isLandingPage && origin && currentDistro" class="products-sidebar">
3
- <div class="group">
4
- <p class="group-title">Дистрибутивы</p>
5
- <a
6
- v-for="d in regular"
7
- :key="d"
8
- :href="`${origin}/${d}/`"
9
- class="item"
10
- :class="{ active: d === currentDistro }"
11
- >{{ productName(d) }}</a>
12
- </div>
13
- <div class="group">
14
- <p class="group-title">Для Эльбрус</p>
15
- <a
16
- v-for="d in e2k"
17
- :key="d"
18
- :href="`${origin}/${d}/`"
19
- class="item"
20
- :class="{ active: d === currentDistro }"
21
- >{{ productName(d) }}</a>
22
- </div>
2
+ <div v-if="isLandingPage && origin" class="products-sidebar">
3
+ <template v-for="group in groups" :key="group.title">
4
+ <div class="group">
5
+ <p v-if="group.title" class="group-title">{{ group.title }}</p>
6
+ <a
7
+ v-for="d in group.distros"
8
+ :key="d"
9
+ :href="distroHref(d)"
10
+ class="item"
11
+ :class="{ active: d === currentDistro }"
12
+ >{{ productName(d) }}</a>
13
+ </div>
14
+ </template>
23
15
  </div>
24
16
  </template>
25
17
 
@@ -27,17 +19,28 @@
27
19
  import { computed, ref, onMounted } from 'vue'
28
20
  import { useRoute, useData } from 'vitepress'
29
21
 
22
+ interface DistroInfo { versions: string[]; latest: string; title?: string }
23
+ interface SectionInfo { name: string; distros: string[] }
24
+ declare const __VERSIONS_DATA__: {
25
+ distros: { [distroName: string]: DistroInfo }
26
+ sections?: SectionInfo[]
27
+ }
28
+
30
29
  const route = useRoute()
31
30
  const { site } = useData()
32
31
  const origin = ref('')
33
32
  onMounted(() => { origin.value = window.location.origin })
34
33
 
35
- const ALL_DISTROS = [
36
- 'alt-domain', 'alt-education', 'alt-kworkstation', 'alt-mobile',
37
- 'alt-platform', 'alt-server', 'alt-server-v', 'alt-virtualisation-one',
38
- 'alt-virtualization-pve', 'alt-workstation', 'group-policy', 'simply-linux',
39
- 'alt-education-e2k', 'alt-server-e2k', 'alt-workstation-e2k', 'simply-linux-e2k',
40
- ]
34
+ const getSafeVersionsData = () => {
35
+ try {
36
+ if (typeof __VERSIONS_DATA__ !== 'undefined') return __VERSIONS_DATA__
37
+ if (typeof window !== 'undefined' && (window as any).__VERSIONS_DATA__)
38
+ return (window as any).__VERSIONS_DATA__
39
+ } catch { /* ignore */ }
40
+ return { distros: {} }
41
+ }
42
+
43
+ const versionsData = getSafeVersionsData()
41
44
 
42
45
  const PRODUCT_NAMES: Record<string, string> = {
43
46
  'alt-domain': 'Альт Домен',
@@ -58,29 +61,62 @@ const PRODUCT_NAMES: Record<string, string> = {
58
61
  'group-policy': 'Групповые политики',
59
62
  }
60
63
 
61
- const productName = (d: string) => PRODUCT_NAMES[d] ?? d
64
+ const productName = (d: string) =>
65
+ PRODUCT_NAMES[d] ?? d.split('-').map(w =>
66
+ w === 'alt' ? 'ALT' : w === 'e2k' ? 'E2K' : w.charAt(0).toUpperCase() + w.slice(1)
67
+ ).join(' ')
62
68
 
63
- const regular = ALL_DISTROS.filter(d => !d.endsWith('-e2k'))
64
- const e2k = ALL_DISTROS.filter(d => d.endsWith('-e2k'))
69
+ const distroHref = (d: string) => origin.value ? `${origin.value}/${d}/` : `/${d}/`
65
70
 
66
- // Strip base from route.path to get content path
71
+ // Strip base from route.path
67
72
  const contentPath = computed(() => {
68
73
  const base = site.value.base
69
- const path = route.path
70
- return base.length > 1 && path.startsWith(base) ? path.slice(base.length - 1) : path
74
+ const p = route.path
75
+ return base.length > 1 && p.startsWith(base) ? p.slice(base.length - 1) : p
71
76
  })
72
77
 
73
- // Show only on the landing page (no version in path like /11.0/...)
78
+ // Show only on the landing page (no version segment like /11.0/…)
74
79
  const isLandingPage = computed(() => {
75
80
  const parts = contentPath.value.split('/').filter(Boolean)
76
81
  return parts.length === 0 || !/^\d+\.\d+/.test(parts[0])
77
82
  })
78
83
 
79
- // Current distro is encoded in the base (per-distro mode)
84
+ // Current distro is encoded in the base in per-distro mode
80
85
  const currentDistro = computed(() => {
81
- const base = site.value.base // e.g. '/alt-domain/'
86
+ const base = site.value.base
82
87
  return base.length > 1 ? base.replace(/\//g, '') : null
83
88
  })
89
+
90
+ interface SidebarGroup { title: string; distros: string[] }
91
+
92
+ const groups = computed((): SidebarGroup[] => {
93
+ const allDistros = Object.keys(versionsData.distros)
94
+ const sections = versionsData.sections ?? []
95
+ const sectionedSet = new Set(sections.flatMap(s => s.distros))
96
+
97
+ const unsectioned = allDistros.filter(d => !sectionedSet.has(d))
98
+ const regular = unsectioned.filter(d => !d.endsWith('-e2k'))
99
+ const e2k = unsectioned.filter(d => d.endsWith('-e2k'))
100
+
101
+ const result: SidebarGroup[] = []
102
+
103
+ if (regular.length > 0) {
104
+ result.push({ title: 'Дистрибутивы', distros: regular })
105
+ }
106
+
107
+ for (const section of sections) {
108
+ const distros = section.distros.filter(d => allDistros.includes(d))
109
+ if (distros.length > 0) {
110
+ result.push({ title: section.name, distros })
111
+ }
112
+ }
113
+
114
+ if (e2k.length > 0) {
115
+ result.push({ title: 'Для Эльбрус', distros: e2k })
116
+ }
117
+
118
+ return result
119
+ })
84
120
  </script>
85
121
 
86
122
  <style scoped>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampernic/vitepress-theme-alt-docs",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Shared VitePress theme for ALT Linux documentation",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "author": "Ampernic",
@@ -33,7 +33,7 @@
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.3",
36
+ "@ampernic/vitepress-plugin-alt-docs-versioning": "0.1.4",
37
37
  "@ampernic/vitepress-plugin-html-image": "0.1.2",
38
38
  "@ampernic/vitepress-plugin-pagefind": "0.1.8",
39
39
  "@ampernic/vitepress-plugin-cross-site-router": "0.1.2"