Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion site/app/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const searchPlaceholder = computed(() => {
return `Search ${packageName} API…`
})

const { defaultApiPath } = useApiCatalog()
const { defaultApiPath, hasMultiplePackages } = useApiCatalog()

const items = computed<NavigationMenuItem[]>(() => [
{
Expand Down Expand Up @@ -174,6 +174,28 @@ const mobileDocsNav = computed(
:navigation="mobileDocsNav"
highlight
/>

<template v-if="route.path.startsWith('/api/')">
<USeparator class="my-4" />

<div class="space-y-3">
<ApiPackageSelect v-if="hasMultiplePackages" />
<ApiVersionSelect />

<p
v-if="apiNavigation.length"
class="mb-2 text-xs font-semibold tracking-wide text-muted uppercase"
>
API
</p>

<UContentNavigation
v-if="apiNavigation.length"
:navigation="apiNavigation"
highlight
/>
</div>
</template>
</template>
</UHeader>

Expand Down
11 changes: 0 additions & 11 deletions site/app/middleware/api-normalize.ts

This file was deleted.

19 changes: 19 additions & 0 deletions site/app/middleware/route-normalize.global.ts
Original file line number Diff line number Diff line change
@@ -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 },
)
})
1 change: 0 additions & 1 deletion site/app/pages/api/[...slug].vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script setup lang="ts">
definePageMeta({
layout: 'api',
middleware: ['api-normalize'],
})

const route = useRoute()
Expand Down
11 changes: 7 additions & 4 deletions site/app/pages/docs/[...slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ definePageMeta({
})

const route = useRoute()
const docsPath = computed(() => route.path.replace(/\/$/, '') || '/')

const { data: page } = await useAsyncData(route.path, () =>
queryCollection('docs').path(route.path).first(),
const { data: page } = await useAsyncData(
() => `docs:${docsPath.value}`,
() => queryCollection('docs').path(docsPath.value).first(),
)

if (!page.value) {
throw createError({ statusCode: 404, statusMessage: 'Page not found', fatal: true })
}

const { data: surround } = await useAsyncData(`${route.path}-surround`, () =>
queryCollectionItemSurroundings('docs', route.path),
const { data: surround } = await useAsyncData(
() => `docs:${docsPath.value}-surround`,
() => queryCollectionItemSurroundings('docs', docsPath.value),
)

useSeoMeta({
Expand Down
Loading