Added YT-like path redirects

This commit is contained in:
WardPearce
2024-04-02 16:46:23 +13:00
parent 884a01e31b
commit f74a792783
2 changed files with 28 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
import { goto } from '$app/navigation';
import { error } from '@sveltejs/kit';
export async function load({ url }) {
const playlistId = url.searchParams.get('list');
if (playlistId) {
goto(`/playlist/${playlistId}`);
} else {
error(404);
}
}
+17
View File
@@ -0,0 +1,17 @@
import { goto } from '$app/navigation';
import { error } from '@sveltejs/kit';
export async function load({ url }) {
const videoId = url.searchParams.get('v');
const playlistId = url.searchParams.get('list');
if (videoId) {
let goToUrl = `/watch/${videoId}`;
if (playlistId) {
goToUrl += `?playlist=${playlistId}`;
}
goto(goToUrl);
} else {
error(404);
}
}