-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
faa65db
commit 458bb44
Showing
6 changed files
with
24 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { defineMiddleware } from "astro:middleware"; | ||
import { defaultLang, languages } from "./i18n"; | ||
|
||
export const onRequest = defineMiddleware(async (ctx, next) => { | ||
if (ctx.url.pathname === "/youtube") { | ||
return Response.redirect("https://youtube.de/@GermanITSkills"); | ||
} | ||
|
||
const [, lang] = ctx.url.pathname.split("/"); | ||
if (!(lang in languages)) { | ||
return Response.redirect( | ||
new URL(`/${defaultLang}${ctx.url.pathname}`, ctx.url), | ||
); | ||
} | ||
|
||
const response = await next(); | ||
|
||
if (response.status === 404) { | ||
return Response.redirect(new URL(`/${lang}/not-found`, ctx.url)); | ||
} | ||
|
||
return response; | ||
}); |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.