From c9ea86866ee2dbcefc4f9758ebc6962f7b756792 Mon Sep 17 00:00:00 2001 From: Matt Maribojoc Date: Tue, 9 Apr 2024 10:23:00 -0400 Subject: [PATCH] docs: configure redirects from vuepress site --- .../middleware/getting-started.global.ts | 6 ------ .../components/middleware/redirects.global.ts | 15 +++++++++++++++ .../pages/[framework]/blocks/[block].vue | 2 +- .../pages/[framework]/components/[component].vue | 2 +- .../components/pages/[framework]/hooks/[hook].vue | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) delete mode 100644 apps/docs/components/middleware/getting-started.global.ts create mode 100644 apps/docs/components/middleware/redirects.global.ts diff --git a/apps/docs/components/middleware/getting-started.global.ts b/apps/docs/components/middleware/getting-started.global.ts deleted file mode 100644 index a88101f86c..0000000000 --- a/apps/docs/components/middleware/getting-started.global.ts +++ /dev/null @@ -1,6 +0,0 @@ -export default defineNuxtRouteMiddleware((to, from) => { - if (to.path === '/getting-started') { - const { selectedFramework } = useFramework(); - return navigateTo('/getting-started/' + selectedFramework.value.name); - } -}); diff --git a/apps/docs/components/middleware/redirects.global.ts b/apps/docs/components/middleware/redirects.global.ts new file mode 100644 index 0000000000..a7f37f9723 --- /dev/null +++ b/apps/docs/components/middleware/redirects.global.ts @@ -0,0 +1,15 @@ +export default defineNuxtRouteMiddleware((to, from) => { + if (to.path === '/getting-started') { + const { selectedFramework } = useFramework(); + return navigateTo('/getting-started/' + selectedFramework.value.name); + } + let path = to.path; + + // remove framework (vue/react) from paths for customization + if (path.includes('/customization') || path.includes('/browser-support') || path.includes('components.html') || path.includes('blocks.html') || path.includes('hooks.html')) { + path = path.replace('/vue', '').replace('/react', ''); + } + if (path.includes('.html')) { + return navigateTo(path.replace('.html', '').toLowerCase()); + } +}); diff --git a/apps/docs/components/pages/[framework]/blocks/[block].vue b/apps/docs/components/pages/[framework]/blocks/[block].vue index d74e428cd3..cfaa1b4364 100644 --- a/apps/docs/components/pages/[framework]/blocks/[block].vue +++ b/apps/docs/components/pages/[framework]/blocks/[block].vue @@ -8,6 +8,6 @@ const route = useRoute(); diff --git a/apps/docs/components/pages/[framework]/components/[component].vue b/apps/docs/components/pages/[framework]/components/[component].vue index 56a8b26307..176bcaaddf 100644 --- a/apps/docs/components/pages/[framework]/components/[component].vue +++ b/apps/docs/components/pages/[framework]/components/[component].vue @@ -8,6 +8,6 @@ const route = useRoute(); diff --git a/apps/docs/components/pages/[framework]/hooks/[hook].vue b/apps/docs/components/pages/[framework]/hooks/[hook].vue index 947e5675ae..e84e0ebd01 100644 --- a/apps/docs/components/pages/[framework]/hooks/[hook].vue +++ b/apps/docs/components/pages/[framework]/hooks/[hook].vue @@ -8,6 +8,6 @@ const route = useRoute();