]> git.lizzy.rs Git - frontend-next.git/blob - src/routes/language.svelte
feat(frontend-next): 0.1.0 :star:
[frontend-next.git] / src / routes / language.svelte
1 <!-- This file is part of api-worker <https://github.com/senpy-club/api-worker>.
2 Copyright (C) 2022-2022 Fuwn <contact@fuwn.me>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, version 3.
7
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 Copyright (C) 2022-2022 Fuwn <contact@fuwn.me>
17 SPDX-License-Identifier: GPL-3.0-only -->
18 <script>
19   import { onMount } from "svelte";
20   import { fetchImages } from "$lib/api";
21   import { page } from "$app/stores";
22
23   let language = $page.url.searchParams.get("language");
24   let images;
25   let complete = false;
26
27   onMount(async () => {
28     images = await fetchImages(language);
29     complete = true;
30   });
31 </script>
32
33 <svelte:head>
34   <title>{language} | senpy-club</title>
35 </svelte:head>
36
37 <div class="content">
38   <h1>{language}</h1>
39
40   {#if !complete}
41     <p>Fetching images...</p>
42   {:else if images.length === 0}
43     <p>Sorry, no images were found for this language.</p>
44   {:else}
45     <ul class="image-rack">
46       {#each images as image}
47         <li id="image-rack-item">
48           <a href={image}>
49             <img
50               src={image}
51               alt="Image of an anime girl holding a programming book"
52             />
53           </a>
54         </li>
55       {/each}
56     </ul>
57   {/if}
58 </div>