mirror of
https://github.com/Kaelio/ktx.git
synced 2026-07-16 11:31:02 +02:00
docs-site: serve under /ktx and redirect ktx.sh to docs.kaelio.com
- Add Next.js basePath '/ktx' so the docs site mounts under /ktx, enabling it to be reverse-proxied by docs.kaelio.com. - Add host-based redirects so docs.ktx.sh and ktx.sh permanently redirect to https://docs.kaelio.com/ktx, making docs.kaelio.com the single canonical home for KTX docs. - Update markdown-preference middleware to be basePath-aware so the llms.mdx rewrite still fires on /ktx/docs/* requests.
This commit is contained in:
parent
cb8902f1e5
commit
c7b64379bf
2 changed files with 22 additions and 2 deletions
|
|
@ -12,12 +12,13 @@ export function middleware(request: NextRequest) {
|
|||
}
|
||||
|
||||
const { pathname } = request.nextUrl;
|
||||
if (!pathname.startsWith("/docs/") || pathname.endsWith(".md")) {
|
||||
const docsIndex = pathname.indexOf("/docs/");
|
||||
if (docsIndex < 0 || pathname.endsWith(".md")) {
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
const rewriteUrl = request.nextUrl.clone();
|
||||
rewriteUrl.pathname = `/llms.mdx${pathname}`;
|
||||
rewriteUrl.pathname = `${pathname.slice(0, docsIndex)}/llms.mdx${pathname.slice(docsIndex)}`;
|
||||
|
||||
return NextResponse.rewrite(rewriteUrl);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue