mirror of
https://github.com/danbulant/Mangades
synced 2026-07-06 19:40:54 +00:00
list chapters
This commit is contained in:
parent
47b22f8f7d
commit
0a4b9d538d
6 changed files with 122 additions and 10 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @roxi/routify 2.18.1
|
* @roxi/routify 2.18.1
|
||||||
* File generated Thu May 20 2021 16:57:51 GMT+0200 (GMT+02:00)
|
* File generated Thu May 20 2021 18:09:03 GMT+0200 (GMT+02:00)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const __version = "2.18.1"
|
export const __version = "2.18.1"
|
||||||
export const __timestamp = "2021-05-20T14:57:51.330Z"
|
export const __timestamp = "2021-05-20T16:09:03.946Z"
|
||||||
|
|
||||||
//buildRoutes
|
//buildRoutes
|
||||||
import { buildClientTree } from "@roxi/routify/runtime/buildRoutes"
|
import { buildClientTree } from "@roxi/routify/runtime/buildRoutes"
|
||||||
|
|
@ -51,6 +51,58 @@ export const _tree = {
|
||||||
"id": "__fallback",
|
"id": "__fallback",
|
||||||
"component": () => import('../src/pages/_fallback.svelte').then(m => m.default)
|
"component": () => import('../src/pages/_fallback.svelte').then(m => m.default)
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"isFile": true,
|
||||||
|
"isDir": true,
|
||||||
|
"file": "_layout.svelte",
|
||||||
|
"filepath": "/[manga]/_layout.svelte",
|
||||||
|
"name": "_layout",
|
||||||
|
"ext": "svelte",
|
||||||
|
"badExt": false,
|
||||||
|
"absolutePath": "/home/dan/Documents/node_projects/mangades/src/pages/[manga]/_layout.svelte",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"isFile": true,
|
||||||
|
"isDir": false,
|
||||||
|
"file": "index.svelte",
|
||||||
|
"filepath": "/[manga]/index.svelte",
|
||||||
|
"name": "index",
|
||||||
|
"ext": "svelte",
|
||||||
|
"badExt": false,
|
||||||
|
"absolutePath": "/home/dan/Documents/node_projects/mangades/src/pages/[manga]/index.svelte",
|
||||||
|
"importPath": "../src/pages/[manga]/index.svelte",
|
||||||
|
"isLayout": false,
|
||||||
|
"isReset": false,
|
||||||
|
"isIndex": true,
|
||||||
|
"isFallback": false,
|
||||||
|
"isPage": true,
|
||||||
|
"ownMeta": {},
|
||||||
|
"meta": {
|
||||||
|
"recursive": true,
|
||||||
|
"preload": "proximity",
|
||||||
|
"prerender": true
|
||||||
|
},
|
||||||
|
"path": "/:manga/index",
|
||||||
|
"id": "__manga_index",
|
||||||
|
"component": () => import('../src/pages/[manga]/index.svelte').then(m => m.default)
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isLayout": true,
|
||||||
|
"isReset": false,
|
||||||
|
"isIndex": false,
|
||||||
|
"isFallback": false,
|
||||||
|
"isPage": false,
|
||||||
|
"importPath": "../src/pages/[manga]/_layout.svelte",
|
||||||
|
"ownMeta": {},
|
||||||
|
"meta": {
|
||||||
|
"recursive": true,
|
||||||
|
"preload": "proximity",
|
||||||
|
"prerender": true
|
||||||
|
},
|
||||||
|
"path": "/:manga",
|
||||||
|
"id": "__manga__layout",
|
||||||
|
"component": () => import('../src/pages/[manga]/_layout.svelte').then(m => m.default)
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"isFile": true,
|
"isFile": true,
|
||||||
"isDir": false,
|
"isDir": false,
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,16 @@ body {
|
||||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
||||||
|
{
|
||||||
|
max-width: 450px;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: rgb(0,100,200);
|
color: rgb(0,100,200);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
|
|
||||||
18
src/pages/[manga]/_layout.svelte
Normal file
18
src/pages/[manga]/_layout.svelte
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<script>
|
||||||
|
import request from "../../util/request";
|
||||||
|
|
||||||
|
export var manga;
|
||||||
|
|
||||||
|
function getManga(id) {
|
||||||
|
return request("manga/" + id);
|
||||||
|
}
|
||||||
|
var mangaData = getManga(manga);
|
||||||
|
$: mangaData = getManga(manga);
|
||||||
|
console.log(mangaData);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#await mangaData}
|
||||||
|
loading...
|
||||||
|
{:then manga}
|
||||||
|
<slot scoped={({ manga: manga.data.attributes, id: manga.data.id })} />
|
||||||
|
{/await}
|
||||||
34
src/pages/[manga]/index.svelte
Normal file
34
src/pages/[manga]/index.svelte
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
<script>
|
||||||
|
import request from "../../util/request";
|
||||||
|
|
||||||
|
export var scoped;
|
||||||
|
|
||||||
|
var mangaId = scoped.id;
|
||||||
|
$: mangaId = scoped.id;
|
||||||
|
var manga = scoped.manga;
|
||||||
|
$: manga = scoped.manga;
|
||||||
|
|
||||||
|
function getMangaChapters(id) {
|
||||||
|
return request("manga/" + id + "/feed");
|
||||||
|
}
|
||||||
|
|
||||||
|
var chapters = getMangaChapters(mangaId);
|
||||||
|
$: chapters = getMangaChapters(mangaId);
|
||||||
|
|
||||||
|
console.log(manga);
|
||||||
|
console.log(chapters);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<h1>{manga.title.en}</h1>
|
||||||
|
|
||||||
|
{#await chapters}
|
||||||
|
Loading chapters...
|
||||||
|
{:then chapters}
|
||||||
|
<ol>
|
||||||
|
{#each chapters.results as chapter}
|
||||||
|
<li>{chapter.data.attributes.title}</li>
|
||||||
|
{/each}
|
||||||
|
</ol>
|
||||||
|
{/await}
|
||||||
|
</main>
|
||||||
|
|
@ -2,11 +2,12 @@
|
||||||
import { params } from '@roxi/routify'
|
import { params } from '@roxi/routify'
|
||||||
import request from "../util/request";
|
import request from "../util/request";
|
||||||
import ratelimit from "../util/ratelimit";
|
import ratelimit from "../util/ratelimit";
|
||||||
|
import { url } from '@roxi/routify/runtime/helpers';
|
||||||
|
|
||||||
var name = $params.search;
|
var name = $params.search;
|
||||||
$: {
|
$: {
|
||||||
const url = new URL(window.location.toString());
|
const url = new URL(window.location.toString());
|
||||||
url.searchParams.set("search", name);
|
url.searchParams.set("search", name || "");
|
||||||
history.replaceState(history.state, "", url.toString());
|
history.replaceState(history.state, "", url.toString());
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
@ -41,7 +42,9 @@
|
||||||
<ul>
|
<ul>
|
||||||
{#each result.results as manga}
|
{#each result.results as manga}
|
||||||
<li>
|
<li>
|
||||||
{manga.data.attributes.title.en}
|
<a href={$url("./" + manga.data.id)}>
|
||||||
|
{manga.data.attributes.title.en}
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
@ -49,11 +52,6 @@
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
main
|
|
||||||
{
|
|
||||||
max-width: 450px;
|
|
||||||
margin: auto;
|
|
||||||
}
|
|
||||||
input {
|
input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
const base = "https://api.mangadex.org/";
|
const base = "https://api.mangadex.org/";
|
||||||
|
|
||||||
function request(endpoint, query, type = "GET", body) {
|
function request(endpoint, query, type = "GET", body) {
|
||||||
return fetch(base + endpoint + "?" + query, {
|
return fetch(base + endpoint + (query ? "?" + query : ""), {
|
||||||
method: type,
|
method: type,
|
||||||
body: body ? JSON.stringify(body) : undefined
|
body: body ? JSON.stringify(body) : undefined
|
||||||
}).then(resp => resp.json());
|
}).then(resp => resp.json());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue