aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-03-08 05:56:17 +0000
committerFuwn <[email protected]>2022-03-08 05:56:17 +0000
commit1073d1ac02a36477cd3bd26798e35c26d5b5b01f (patch)
tree194ecdc7f671521536a021ae63f0d717159e2d53 /src/lib
downloadarchived-frontend-next-1073d1ac02a36477cd3bd26798e35c26d5b5b01f.tar.xz
archived-frontend-next-1073d1ac02a36477cd3bd26798e35c26d5b5b01f.zip
feat(frontend-next): 0.1.0 :star:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/api.ts44
-rw-r--r--src/lib/header/Header.svelte33
2 files changed, 77 insertions, 0 deletions
diff --git a/src/lib/api.ts b/src/lib/api.ts
new file mode 100644
index 0000000..58ed028
--- /dev/null
+++ b/src/lib/api.ts
@@ -0,0 +1,44 @@
+// This file is part of frontend-next <https://github.com/senpy-club/frontend-next>.
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, version 3.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+// SPDX-License-Identifier: GPL-3.0-only
+
+const baseUrl = "https://senpy-club-api-worker.fuwn.workers.dev/v2";
+
+interface RandomImage {
+ language: string;
+ image: string;
+}
+
+export async function fetchImages(language: string): Promise<string[]> {
+ language = language.replace("#", "%23");
+
+ const response = await fetch(`${baseUrl}/language/${language}`);
+
+ return await response.json();
+}
+
+export async function fetchLanguages(): Promise<string[]> {
+ const response = await fetch(`${baseUrl}/languages`);
+
+ return await response.json();
+}
+
+export async function fetchRandomImage(): Promise<RandomImage> {
+ const response = await fetch(`${baseUrl}/random`);
+
+ return await response.json();
+}
diff --git a/src/lib/header/Header.svelte b/src/lib/header/Header.svelte
new file mode 100644
index 0000000..0b0909e
--- /dev/null
+++ b/src/lib/header/Header.svelte
@@ -0,0 +1,33 @@
+<!-- This file is part of api-worker <https://github.com/senpy-club/api-worker>.
+Copyright (C) 2022-2022 Fuwn <[email protected]>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 3.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Copyright (C) 2022-2022 Fuwn <[email protected]>
+SPDX-License-Identifier: GPL-3.0-only -->
+
+<header>
+ <nav>
+ Route senpy[3] = [
+ <a sveltekit:prefetch href="/">home</a>,
+ <a sveltekit:prefetch href="/languages">languages</a>,
+ <a
+ sveltekit:prefetch
+ href="https://senpy-club-api-worker.fuwn.workers.dev/"
+ target="_blank"
+ >
+ api
+ </a>
+ ];
+ </nav>
+</header>