Skip to content

Commit d9d75ca

Browse files
w1amalexeyzimarevrb-kurrent
authored
[DEV-367] Import client docs (#903)
Co-authored-by: Alexey Zimarev <alex@zimarev.com> Co-authored-by: Ryan B <197610600+rb-kurrent@users.noreply.github.com>
1 parent 15be5cd commit d9d75ca

File tree

138 files changed

+2472
-6949
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+2472
-6949
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,3 +344,7 @@ generated-versions.json
344344
docs/.vuepress/.temp/
345345
docs/.vuepress/.cache/
346346
docs/.vuepress/dist/
347+
348+
config.ts.*.mjs
349+
350+
docs/clients/grpc/**/*

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Configuration for sidebars can be found in the `/docs/.vuepress/configs/sidebar.
164164

165165
```typescript
166166
export const sidebarEn: EsSidebarOptions = {
167-
"/clients/grpc/": "structure",
167+
"/clients/": "structure",
168168
"/cloud/": "structure",
169169
}
170170
```

docs/.vuepress/client.ts

Lines changed: 56 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,25 @@ import CloudBanner from "./components/CloudBanner.vue";
66
import KapaWidget from './components/KapaWidget.vue';
77
import UserFeedback from './components/TocWithFeedback';
88
import {usePostHog} from "./lib/usePosthog";
9+
import SidebarLayout from "./layouts/SidebarLayout.vue";
910

10-
declare const __VERSIONS__: { latest: string, selected: string, all: string[] }
11+
declare const __VERSIONS__: {
12+
latest: string,
13+
selected: string,
14+
all: {
15+
id: string,
16+
group: string,
17+
basePath: string,
18+
versions: {
19+
version: string,
20+
path: string,
21+
startPage: string,
22+
preview?: boolean,
23+
deprecated?: boolean,
24+
hide?: boolean
25+
}[]
26+
}[]
27+
}
1128

1229
const storageKey = "VUEPRESS_TAB_STORE";
1330

@@ -30,15 +47,6 @@ const findEsMeta = (route) => {
3047
}
3148
}
3249

33-
interface ClientConfig {
34-
enhance?: (context: {
35-
app: any;
36-
router: Router;
37-
siteData: any;
38-
}) => void | Promise<void>;
39-
setup?: () => void;
40-
}
41-
4250
const removeHtml = (path: string) => path.replace(".html", "");
4351

4452
const reload = () => {
@@ -55,14 +63,16 @@ const leave = (to: RouteLocationNormalized, from: RouteLocationNormalized) => {
5563
}
5664
}
5765

58-
const { posthog } = usePostHog();
66+
const {posthog} = usePostHog();
5967

6068
export default defineClientConfig({
69+
layouts: {
70+
Layout: SidebarLayout
71+
},
6172
enhance({app, router, _}) {
6273
app.component("CloudBanner", CloudBanner);
6374
app.component("KapaWidget", KapaWidget);
6475
app.component("UserFeedback", UserFeedback);
65-
const apiPath = __VERSIONS__.latest.replace("server", "http-api");
6676
const addFixedRoute = (from: string, to: string) => router.addRoute({
6777
path: from, redirect: _ => {
6878
reload();
@@ -79,16 +89,16 @@ export default defineClientConfig({
7989
});
8090

8191
// Router configuration
82-
addFixedRoute("/http-api/", `${apiPath}/introduction`);
92+
addFixedRoute("/server/http-api/", `/${__VERSIONS__.latest}/http-api/introduction`);
8393
addFixedRoute("/cloud/", `/cloud/introduction.html`);
8494
router.afterEach(() => {
8595
setTimeout(() => { // to ensure this runs after DOM updates
8696
try {
87-
const {code} = JSON.parse(localStorage.getItem('VUEPRESS_TAB_STORE'));
97+
const {code} = JSON.parse(localStorage.getItem('VUEPRESS_TAB_STORE')!);
8898
if (code) { // If a valid 'code' is found in localStorage
8999
Array.from(document.querySelectorAll('.vp-tab-nav'))
90100
.forEach((button: HTMLButtonElement) => {
91-
if (button.textContent.trim() === code) {
101+
if (button.textContent!.trim() === code) {
92102
button.click(); // click the button to switch the tab
93103
}
94104
});
@@ -98,18 +108,36 @@ export default defineClientConfig({
98108
}
99109
}, 0);
100110
});
101-
const operatorLatest = __VERSIONS__.all.filter(x => x.id == 'kubernetes-operator')[0].versions[0].version;
111+
const operatorLatest = __VERSIONS__.all.filter(x => x.id === 'kubernetes-operator')[0].versions[0].version;
102112
addDynamicRoute("/server/kubernetes-operator", to => `/server/kubernetes-operator/${operatorLatest}/getting-started/`);
103113
addDynamicRoute("/server/kubernetes-operator/:version", to => `/server/kubernetes-operator/${to.params.version}/getting-started/`);
104114

115+
addDynamicRoute('/clients/:lang(dotnet|golang|java|node|python|rust)/legacy/:version', to => {
116+
const version = to.params.version;
117+
const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions.find(v => v.path === `legacy/${version}`)
118+
return `/clients/${to.params.lang}/legacy/${to.params.version}/${latestVersion?.startPage}`;
119+
});
120+
addDynamicRoute('/clients/:lang(dotnet|golang|java|node|python|rust)/legacy', to => {
121+
const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions.find(v => v.path.startsWith('legacy/'))
122+
return `/clients/${to.params.lang}/${latestVersion?.path}/${latestVersion?.startPage}`;
123+
})
124+
125+
addDynamicRoute('/clients/:lang(dotnet|golang|java|node|python|rust)/:version', to => {
126+
const version = to.params.version;
127+
const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions.find(v => v.path === version)
128+
return `/clients/${to.params.lang}/${version}/${latestVersion?.startPage}`;
129+
});
130+
addDynamicRoute('/clients/:lang(dotnet|golang|java|node|python|rust)', to => {
131+
const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions[0]
132+
return `/clients/${to.params.lang}/${latestVersion?.path}/${latestVersion?.startPage}`;
133+
})
134+
135+
136+
// Add fixed routes for server versions because they don't use the same sidebar structure as the other versions
137+
addFixedRoute("/server/v22.10", "/server/v22.10/introduction.html");
138+
addFixedRoute("/server/v5", "/server/v5/introduction.html");
139+
105140
addDynamicRoute("/server/:version", to => `/server/${to.params.version}/quick-start/`);
106-
addDynamicRoute('/client/:lang',
107-
to => {
108-
const lang = to.params.lang === "csharp" ? "C#" : to.params.lang;
109-
const stored = JSON.parse(localStorage.getItem(storageKey) ?? "{}");
110-
localStorage.setItem(storageKey, JSON.stringify({...stored, code: lang}));
111-
return '/clients/grpc/getting-started.html';
112-
});
113141
addDynamicRoute('/latest/:pathMatch(.*)*', to => to.path.replace(/^\/latest/, `/${__VERSIONS__.latest}`));
114142
addFixedRoute("/server/latest", `/${__VERSIONS__.latest}/quick-start/`);
115143
addFixedRoute("/latest", `/${__VERSIONS__.latest}/quick-start/`);
@@ -135,13 +163,13 @@ export default defineClientConfig({
135163
});
136164
}, 1000);
137165
}
138-
166+
139167
// Check for 404 page after navigation completes
140168
setTimeout(() => {
141169
// Check for the specific elements with classes error-code and error-hint
142170
const errorCodeElement = document.querySelector('p.error-code');
143171
const errorHintElement = document.querySelector('p.error-hint');
144-
172+
145173
// If both elements exist, we're on a 404 page
146174
if (errorCodeElement && errorHintElement) {
147175
// Capture the 404 event in PostHog
@@ -154,15 +182,15 @@ export default defineClientConfig({
154182
});
155183
}
156184
}
157-
}, 50);
185+
}, 50);
158186
});
159187
router.beforeEach((to, from) => leave(to, from));
160188
},
161189
setup() {
162190
onMounted(() => {
163191
const route = useRoute();
164-
if (route.path !== "/");
192+
if (route.path !== "/") ;
165193
});
166194

167195
},
168-
} satisfies ClientConfig);
196+
});

docs/.vuepress/components/KapaWidget.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<script setup>
22
function triggerKapa() {
33
window.Kapa.open();
4-
54
}
65
</script>
76

docs/.vuepress/components/TocWithFeedback.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import {
2020
usePageFrontmatter,
2121
useRoute,
2222
} from "vuepress/client";
23-
import PrintButton from "vuepress-theme-hope/modules/info/components/PrintButton";
24-
import { useMetaLocale } from "vuepress-theme-hope/modules/info/composables/index";
23+
import PrintButton from "vuepress-theme-hope/components/base/PrintButton";
24+
import { useMetaLocale } from "vuepress-theme-hope/composables/info/index";
2525

2626
import "../styles/toc.scss";
2727

docs/.vuepress/components/Version.vue

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)