diff --git a/site/app/app.vue b/site/app/app.vue index 2e3f640..7867829 100644 --- a/site/app/app.vue +++ b/site/app/app.vue @@ -54,7 +54,7 @@ const searchPlaceholder = computed(() => { return `Search ${packageName} API…` }) -const { defaultApiPath } = useApiCatalog() +const { defaultApiPath, hasMultiplePackages } = useApiCatalog() const items = computed(() => [ { @@ -174,6 +174,28 @@ const mobileDocsNav = computed( :navigation="mobileDocsNav" highlight /> + + diff --git a/site/app/middleware/api-normalize.ts b/site/app/middleware/api-normalize.ts deleted file mode 100644 index 04e2f90..0000000 --- a/site/app/middleware/api-normalize.ts +++ /dev/null @@ -1,11 +0,0 @@ -export default defineNuxtRouteMiddleware((to) => { - if (!to.path.startsWith('/api/')) return - - const normalized = to.path.toLowerCase().replace(/\/$/, '') - if (to.path === normalized) return - - return navigateTo( - { path: normalized, hash: to.hash, query: to.query }, - { replace: true }, - ) -}) diff --git a/site/app/middleware/route-normalize.global.ts b/site/app/middleware/route-normalize.global.ts new file mode 100644 index 0000000..2cb5712 --- /dev/null +++ b/site/app/middleware/route-normalize.global.ts @@ -0,0 +1,19 @@ +/** Strip trailing slashes (GitHub Pages directory URLs) and normalize API casing. */ +export default defineNuxtRouteMiddleware((to) => { + let normalized = to.path + + if (normalized.startsWith('/api/')) { + normalized = normalized.toLowerCase() + } + + if (normalized.length > 1 && normalized.endsWith('/')) { + normalized = normalized.slice(0, -1) + } + + if (normalized === to.path) return + + return navigateTo( + { path: normalized, hash: to.hash, query: to.query }, + { replace: true }, + ) +}) diff --git a/site/app/pages/api/[...slug].vue b/site/app/pages/api/[...slug].vue index 343ad9f..c6c4dcd 100644 --- a/site/app/pages/api/[...slug].vue +++ b/site/app/pages/api/[...slug].vue @@ -1,7 +1,6 @@