diff --git a/docs-site/src/index.ts b/docs-site/src/index.ts index b79ef923ad..2b535cf8a1 100644 --- a/docs-site/src/index.ts +++ b/docs-site/src/index.ts @@ -3,10 +3,23 @@ export default { const r = await env.ASSETS.fetch(request) if (r.status == 404) { const url = new URL(request.url) + const redirectPath = redirect(url.pathname) + if (redirectPath) { + url.pathname = redirectPath + return Response.redirect(url.toString(), 301) + } url.pathname = '/404.html' const r = await env.ASSETS.fetch(url) - return new Response(r.body, { status: 404 }) + return new Response(r.body, { status: 404, headers: {'content-type': 'text/html'} }) } return r }, } satisfies ExportedHandler + +const redirect_lookup: Record = { + '/common_tools': '/common-tools/', +} + +function redirect(pathname: string): string | null { + return redirect_lookup[pathname.replace(/\/+$/, '')] ?? null +} diff --git a/docs-site/wrangler.toml b/docs-site/wrangler.toml index 068a90aba2..d99b9701d9 100644 --- a/docs-site/wrangler.toml +++ b/docs-site/wrangler.toml @@ -1,6 +1,6 @@ #:schema node_modules/wrangler/config-schema.json name = "pydantic-ai" -compatibility_date = "2025-01-29" +compatibility_date = "2025-01-24" routes = ["ai.pydantic.dev/*"] main = "src/index.ts" workers_dev = false diff --git a/docs/common_tools.md b/docs/common-tools.md similarity index 100% rename from docs/common_tools.md rename to docs/common-tools.md diff --git a/mkdocs.yml b/mkdocs.yml index 8c17e1aff4..0659d8c02e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -20,7 +20,7 @@ nav: - models.md - dependencies.md - tools.md - - common_tools.md + - common-tools.md - results.md - message-history.md - testing-evals.md