From c9da493b32ec8b2f10c475a20c2d1e4c9928dd82 Mon Sep 17 00:00:00 2001 From: Alexey Zimarev Date: Mon, 23 Jun 2025 21:40:38 +0200 Subject: [PATCH 01/13] Experiment with versions --- docs/.vuepress/client.ts | 36 +- docs/.vuepress/components/TocWithFeedback.ts | 4 +- docs/.vuepress/components/Version.vue | 26 +- docs/.vuepress/configs/sidebar.ts | 77 +- docs/.vuepress/layouts/Layout.vue | 12 + package.json | 25 +- pnpm-lock.yaml | 12204 +++++++++++++++++ 7 files changed, 12300 insertions(+), 84 deletions(-) create mode 100644 docs/.vuepress/layouts/Layout.vue create mode 100644 pnpm-lock.yaml diff --git a/docs/.vuepress/client.ts b/docs/.vuepress/client.ts index cbbc5565c..b4870f5f8 100644 --- a/docs/.vuepress/client.ts +++ b/docs/.vuepress/client.ts @@ -6,6 +6,7 @@ import CloudBanner from "./components/CloudBanner.vue"; import KapaWidget from './components/KapaWidget.vue'; import UserFeedback from './components/TocWithFeedback'; import {usePostHog} from "./lib/usePosthog"; +import Layout from "./layouts/Layout.vue"; declare const __VERSIONS__: { latest: string, selected: string, all: string[] } @@ -30,14 +31,14 @@ const findEsMeta = (route) => { } } -interface ClientConfig { - enhance?: (context: { - app: any; - router: Router; - siteData: any; - }) => void | Promise; - setup?: () => void; -} +// interface ClientConfig { +// enhance?: (context: { +// app: any; +// router: Router; +// siteData: any; +// }) => void | Promise; +// setup?: () => void; +// } const removeHtml = (path: string) => path.replace(".html", ""); @@ -55,9 +56,12 @@ const leave = (to: RouteLocationNormalized, from: RouteLocationNormalized) => { } } -const { posthog } = usePostHog(); +const {posthog} = usePostHog(); export default defineClientConfig({ + layouts: { + Layout + }, enhance({app, router, _}) { app.component("CloudBanner", CloudBanner); app.component("KapaWidget", KapaWidget); @@ -84,11 +88,11 @@ export default defineClientConfig({ router.afterEach(() => { setTimeout(() => { // to ensure this runs after DOM updates try { - const {code} = JSON.parse(localStorage.getItem('VUEPRESS_TAB_STORE')); + const {code} = JSON.parse(localStorage.getItem('VUEPRESS_TAB_STORE')!); if (code) { // If a valid 'code' is found in localStorage Array.from(document.querySelectorAll('.vp-tab-nav')) .forEach((button: HTMLButtonElement) => { - if (button.textContent.trim() === code) { + if (button.textContent!.trim() === code) { button.click(); // click the button to switch the tab } }); @@ -135,13 +139,13 @@ export default defineClientConfig({ }); }, 1000); } - + // Check for 404 page after navigation completes setTimeout(() => { // Check for the specific elements with classes error-code and error-hint const errorCodeElement = document.querySelector('p.error-code'); const errorHintElement = document.querySelector('p.error-hint'); - + // If both elements exist, we're on a 404 page if (errorCodeElement && errorHintElement) { // Capture the 404 event in PostHog @@ -154,15 +158,15 @@ export default defineClientConfig({ }); } } - }, 50); + }, 50); }); router.beforeEach((to, from) => leave(to, from)); }, setup() { onMounted(() => { const route = useRoute(); - if (route.path !== "/"); + if (route.path !== "/") ; }); }, -} satisfies ClientConfig); \ No newline at end of file +}); \ No newline at end of file diff --git a/docs/.vuepress/components/TocWithFeedback.ts b/docs/.vuepress/components/TocWithFeedback.ts index 9f095c6a8..ec342c8fe 100644 --- a/docs/.vuepress/components/TocWithFeedback.ts +++ b/docs/.vuepress/components/TocWithFeedback.ts @@ -20,8 +20,8 @@ import { usePageFrontmatter, useRoute, } from "vuepress/client"; -import PrintButton from "vuepress-theme-hope/modules/info/components/PrintButton"; -import { useMetaLocale } from "vuepress-theme-hope/modules/info/composables/index"; +import PrintButton from "vuepress-theme-hope/components/base/PrintButton"; +import { useMetaLocale } from "vuepress-theme-hope/composables/info/index"; import "../styles/toc.scss"; diff --git a/docs/.vuepress/components/Version.vue b/docs/.vuepress/components/Version.vue index 55feabbd7..998610ad9 100644 --- a/docs/.vuepress/components/Version.vue +++ b/docs/.vuepress/components/Version.vue @@ -1,34 +1,30 @@ - - \ No newline at end of file diff --git a/docs/.vuepress/config.ts b/docs/.vuepress/config.ts index 00952d62e..4eafcde48 100644 --- a/docs/.vuepress/config.ts +++ b/docs/.vuepress/config.ts @@ -1,10 +1,11 @@ +/* eslint-disable import/no-named-as-default */ + import {dl} from "@mdit/plugin-dl"; import viteBundler from "@vuepress/bundler-vite"; -import dotenv from 'dotenv'; +import dotenv from "dotenv" import vueDevTools from 'vite-plugin-vue-devtools' import {defineUserConfig} from "vuepress"; import {path} from 'vuepress/utils'; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment import {hopeTheme} from "vuepress-theme-hope"; import {themeOptions} from "./configs/theme"; import {projectionSamplesPath, resolveMultiSamplesPath} from "./lib/samples"; @@ -39,6 +40,12 @@ export default defineUserConfig({ importCode: false, headers: {level: [2, 3]}, }, + pagePatterns: [ + '**/*.md', + '!**/v*/README.md', + '!.vuepress', + '!node_modules' + ], extendsMarkdown: md => { md.use(replaceLinkPlugin, { replaceLink: (link: string, _) => link diff --git a/docs/.vuepress/layouts/SidebarLayout.vue b/docs/.vuepress/layouts/SidebarLayout.vue index 12f8294d3..e43b579e4 100644 --- a/docs/.vuepress/layouts/SidebarLayout.vue +++ b/docs/.vuepress/layouts/SidebarLayout.vue @@ -18,7 +18,10 @@ interface ExtendedPageData extends Record { const pageData = usePageData() const route = useRoute() -const version = computed(() => { +/** + * Find which version of documentation the user is currently viewing based on the URL path + */ +const versionInfo = computed(() => { const pathSegments = route.path.split('/').filter(segment => segment !== '') if (pathSegments.length < 2) @@ -35,7 +38,7 @@ const version = computed(() => { const versionPath = versionDetail.path if (route.path.includes(`/${basePath}/${versionPath}/`)) { return { - version: versionInfo.versions, + versions: versionInfo.versions, current: versionDetail.version } } @@ -49,8 +52,8 @@ const version = computed(() => {