aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Reader
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-10-09 00:41:20 -0700
committerFuwn <[email protected]>2024-10-09 00:41:43 -0700
commit998b63a35256ac985a5a2714dd1ca451af4dfd8a (patch)
tree50796121a9d5ab0330fdc5d7e098bda2860d9726 /src/lib/Reader
parentfeat(graphql): add badgeCount field (diff)
downloaddue.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.tar.xz
due.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.zip
chore(prettier): use spaces instead of tabs
Diffstat (limited to 'src/lib/Reader')
-rw-r--r--src/lib/Reader/Chapters/MangaDex.svelte34
-rw-r--r--src/lib/Reader/Chapters/Rawkuma.svelte30
-rw-r--r--src/lib/Reader/resource.ts50
3 files changed, 57 insertions, 57 deletions
diff --git a/src/lib/Reader/Chapters/MangaDex.svelte b/src/lib/Reader/Chapters/MangaDex.svelte
index 12eca713..44c0d8f6 100644
--- a/src/lib/Reader/Chapters/MangaDex.svelte
+++ b/src/lib/Reader/Chapters/MangaDex.svelte
@@ -1,22 +1,22 @@
<script lang="ts">
- export let data: any;
+ export let data: any;
</script>
<ul>
- {#each data.data as chapter}
- <li>
- {#if chapter.attributes.volume}
- Vol. {chapter.attributes.volume}
- {/if}
- Ch. {chapter.attributes.chapter}
- <span class="opaque">|</span>
- <a
- href={`https://mangadex.org/chapter/${chapter.id}`}
- target="_blank"
- rel="noopener noreferrer"
- >
- {chapter.attributes.title || 'Read'}
- </a>
- </li>
- {/each}
+ {#each data.data as chapter}
+ <li>
+ {#if chapter.attributes.volume}
+ Vol. {chapter.attributes.volume}
+ {/if}
+ Ch. {chapter.attributes.chapter}
+ <span class="opaque">|</span>
+ <a
+ href={`https://mangadex.org/chapter/${chapter.id}`}
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ {chapter.attributes.title || 'Read'}
+ </a>
+ </li>
+ {/each}
</ul>
diff --git a/src/lib/Reader/Chapters/Rawkuma.svelte b/src/lib/Reader/Chapters/Rawkuma.svelte
index 5a7e57ad..720c65d5 100644
--- a/src/lib/Reader/Chapters/Rawkuma.svelte
+++ b/src/lib/Reader/Chapters/Rawkuma.svelte
@@ -1,22 +1,22 @@
<script lang="ts">
- import { getChaptersFromText } from '$lib/Data/Manga/raw';
- import { onMount } from 'svelte';
+ import { getChaptersFromText } from '$lib/Data/Manga/raw';
+ import { onMount } from 'svelte';
- export let data: string;
+ export let data: string;
- onMount(() => {
- console.log();
- });
+ onMount(() => {
+ console.log();
+ });
</script>
<ul>
- {#each getChaptersFromText(data) as chapter}
- <li>
- {chapter.chapterDate}
- <span class="opaque">|</span>
- <a href={chapter.href} target="_blank" rel="noopener noreferrer">
- {chapter.chapterNum}
- </a>
- </li>
- {/each}
+ {#each getChaptersFromText(data) as chapter}
+ <li>
+ {chapter.chapterDate}
+ <span class="opaque">|</span>
+ <a href={chapter.href} target="_blank" rel="noopener noreferrer">
+ {chapter.chapterNum}
+ </a>
+ </li>
+ {/each}
</ul>
diff --git a/src/lib/Reader/resource.ts b/src/lib/Reader/resource.ts
index b96a890f..2ee606b0 100644
--- a/src/lib/Reader/resource.ts
+++ b/src/lib/Reader/resource.ts
@@ -1,40 +1,40 @@
export enum Resource {
- MangaDex = 'MangaDex',
- Rawkuma = 'Rawkuma'
+ MangaDex = 'MangaDex',
+ Rawkuma = 'Rawkuma'
}
export const identify = (url: string): Resource | undefined => {
- if (url.match(/mangadex\.org\/title\/([a-f0-9-]+)\/?/)?.[1]) {
- return Resource.MangaDex;
- } else if (url.match(/rawkuma\.com\/manga\/([a-z0-9-]+)\/?/)?.[1]) {
- return Resource.Rawkuma;
- }
+ if (url.match(/mangadex\.org\/title\/([a-f0-9-]+)\/?/)?.[1]) {
+ return Resource.MangaDex;
+ } else if (url.match(/rawkuma\.com\/manga\/([a-z0-9-]+)\/?/)?.[1]) {
+ return Resource.Rawkuma;
+ }
- return undefined;
+ return undefined;
};
export const fetchResource = async (url: string) => {
- const resource = identify(url);
+ const resource = identify(url);
- if (resource === Resource.MangaDex) {
- return await fetch(
- `https://api.mangadex.org/manga/${
- url.match(/mangadex\.org\/title\/([a-f0-9-]+)\/?/)?.[1]
- }/feed?order[chapter]=desc&translatedLanguage[]=en`
- );
- } else if (resource === Resource.Rawkuma) {
- return await fetch(url);
- }
+ if (resource === Resource.MangaDex) {
+ return await fetch(
+ `https://api.mangadex.org/manga/${
+ url.match(/mangadex\.org\/title\/([a-f0-9-]+)\/?/)?.[1]
+ }/feed?order[chapter]=desc&translatedLanguage[]=en`
+ );
+ } else if (resource === Resource.Rawkuma) {
+ return await fetch(url);
+ }
- return fetch(url);
+ return fetch(url);
};
export const decodeResource = async (response: Response, url: string) => {
- const resource = identify(url);
+ const resource = identify(url);
- if (resource === Resource.MangaDex) {
- return await response.json();
- } else {
- return await response.text();
- }
+ if (resource === Resource.MangaDex) {
+ return await response.json();
+ } else {
+ return await response.text();
+ }
};