@ampernic/vitepress-theme-alt-docs 0.1.12 → 0.1.14
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
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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,62 +61,93 @@ const PRODUCT_NAMES: Record<string, string> = {
|
|
|
58
61
|
'group-policy': 'Групповые политики',
|
|
59
62
|
}
|
|
60
63
|
|
|
61
|
-
const productName = (d: string) =>
|
|
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
|
|
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
|
|
71
|
+
// Strip base from route.path
|
|
67
72
|
const contentPath = computed(() => {
|
|
68
73
|
const base = site.value.base
|
|
69
|
-
const
|
|
70
|
-
return base.length > 1 &&
|
|
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
|
|
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
|
|
84
|
+
// Current distro is encoded in the base in per-distro mode
|
|
80
85
|
const currentDistro = computed(() => {
|
|
81
|
-
const base = site.value.base
|
|
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: SectionInfo) => 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: string) => 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>
|
|
87
|
-
.products-sidebar {
|
|
88
|
-
padding: 12px 0;
|
|
89
|
-
}
|
|
90
123
|
.group {
|
|
91
|
-
|
|
124
|
+
padding-bottom: 24px;
|
|
92
125
|
}
|
|
93
126
|
.group-title {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
margin: 0 0 6px;
|
|
127
|
+
padding: 4px 0;
|
|
128
|
+
line-height: 24px;
|
|
129
|
+
font-size: 14px;
|
|
130
|
+
font-weight: 700;
|
|
131
|
+
color: var(--vp-c-text-1);
|
|
132
|
+
transition: color 0.25s;
|
|
101
133
|
}
|
|
102
134
|
.item {
|
|
103
135
|
display: block;
|
|
104
|
-
padding: 4px
|
|
136
|
+
padding: 4px 0;
|
|
137
|
+
line-height: 24px;
|
|
105
138
|
font-size: 14px;
|
|
106
|
-
|
|
139
|
+
font-weight: 500;
|
|
140
|
+
color: var(--vp-c-text-2);
|
|
107
141
|
text-decoration: none;
|
|
108
|
-
|
|
109
|
-
|
|
142
|
+
transition: color 0.25s;
|
|
143
|
+
white-space: nowrap;
|
|
144
|
+
overflow: hidden;
|
|
145
|
+
text-overflow: ellipsis;
|
|
110
146
|
}
|
|
111
147
|
.item:hover {
|
|
112
148
|
color: var(--vp-c-brand-1);
|
|
113
|
-
background: var(--vp-c-default-soft);
|
|
114
149
|
}
|
|
115
150
|
.item.active {
|
|
116
151
|
color: var(--vp-c-brand-1);
|
|
117
|
-
font-weight: 600;
|
|
118
152
|
}
|
|
119
153
|
</style>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ampernic/vitepress-theme-alt-docs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "Shared VitePress theme for ALT Linux documentation",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"author": "Ampernic",
|
|
@@ -33,9 +33,9 @@
|
|
|
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.4",
|
|
37
36
|
"@ampernic/vitepress-plugin-cross-site-router": "0.1.2",
|
|
38
37
|
"@ampernic/vitepress-plugin-html-image": "0.1.2",
|
|
38
|
+
"@ampernic/vitepress-plugin-alt-docs-versioning": "0.1.4",
|
|
39
39
|
"@ampernic/vitepress-plugin-pagefind": "0.1.8"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|