make random a page

This commit is contained in:
Daniel Bulant 2022-12-09 19:31:38 +01:00
parent fffd98425a
commit 0254300cf1
2 changed files with 8 additions and 8 deletions

View file

@ -90,13 +90,6 @@
}
}
var randomMangaLoading = false;
async function randomManga() {
randomMangaLoading = true;
const res = await request("manga/random");
goto("./" + res.data.id);
}
function open() {
var id = name;
if(id.startsWith("https://mangadex.org/title/")) {
@ -132,7 +125,7 @@
</div>
<div class="flex">
<button on:click={randomManga} disabled={randomMangaLoading}>Random</button>
<a href="/random" class="button">Random</a>
{#if isLogedIn()}
{#await userDetails then userDetails}
<a href="https://anilist.co/user/{userDetails.data.User.name}" target="_blank">

View file

@ -0,0 +1,7 @@
import request from "$lib/util/request";
import { redirect } from "@sveltejs/kit";
export async function load() {
const res = await request("manga/random");
throw redirect(307, "./" + res.data.id);
}