Skip to content
Open
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
17 changes: 17 additions & 0 deletions app/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,20 @@ html > body[data-scroll-locked] {
code {
tab-size: 4;
}

/* version switcher: match the search field, placed above it */
#nd-sidebar button:has(> .lucide-chevrons-up-down) {
@apply inline-flex items-center gap-2 rounded-lg border p-1.5 ps-2 text-sm text-fd-muted-foreground;
background-color: var(--color-gray-900);
order: 1;
margin-bottom: -0.375rem;
}

#nd-sidebar button[data-search-full] {
order: 2;
}

#nd-sidebar button:has(> .lucide-chevrons-up-down):hover,
#nd-sidebar button:has(> .lucide-chevrons-up-down)[data-state='open'] {
@apply bg-fd-accent text-fd-accent-foreground;
}
16 changes: 16 additions & 0 deletions app/routes/docs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useFumadocsLoader } from 'fumadocs-core/source/client'
import { DocsLayout } from 'fumadocs-ui/layouts/docs'
import { DocsBody, DocsDescription, DocsPage, DocsTitle } from 'fumadocs-ui/layouts/docs/page'
import { use } from 'react'
import { redirect } from 'react-router'
import { Breadcrumb } from '@/components/breadcrumb'
import { Feedback } from '@/components/feedback/client'
import { useMDXComponents } from '@/components/mdx'
Expand All @@ -11,10 +12,25 @@ import { baseOptions } from '@/lib/layout.shared'
import { docs, source } from '@/lib/source'
import type { Route } from './+types/docs'

// Pre-versioning paths (e.g. /docs/godot/install) redirect to the 1.x version.
const LEGACY_SECTIONS = ['godot', 'unity', 'http', 'sockets', 'selfhosting', 'integrations']
const VERSION_REDIRECTS: Record<string, string> = {
'1.0': '1.x',
'0.49': 'pre-1.0',
'0.60': 'pre-1.0',
}

export async function loader({ params }: Route.LoaderArgs) {
const slugs = params['*'].split('/').filter((v) => v.length > 0)
const page = source.getPage(slugs)
if (!page) {
const first = slugs[0] ?? ''
if (LEGACY_SECTIONS.includes(first)) {
throw redirect(`/docs/1.x/${slugs.join('/')}`)
}
if (VERSION_REDIRECTS[first]) {
throw redirect(`/docs/${VERSION_REDIRECTS[first]}/${slugs.slice(1).join('/')}`)
}
throw new Response('Not found', { status: 404 })
}

Expand Down
Loading
Loading