Files
Anitrack/frontend/src/helperComponents/WebsiteLink.svelte
John O'Keefe c510c2a138 feat(frontend): add genre display UI and enhance link component
- Anime.svelte: Add genre display section with clickable badges that link
  to AniList search results for each genre. Genres are now displayed above
  the existing tags section with consistent styling.

- WebsiteLink.svelte: Enhance component to support custom URLs via the `url`
  export parameter. Previously, the component only generated URLs based on
  service prefixes (a-, m-, s-). Now it accepts a direct URL parameter for
  flexible linking to AniList searches and other external resources.

These changes provide users with an improved browsing experience by making
genres interactive and easily searchable.
2026-03-19 21:09:27 -04:00

33 lines
907 B
Svelte

<script lang="ts">
import { BrowserOpenURL } from "../../wailsjs/runtime";
export let id: string;
export let url = "";
let isAniList = false;
let isMAL = false;
let isSimkl = false;
let newId = id;
let re = /[ams]?-?(.*)/;
if (id !== undefined && id.length > 0) {
isAniList = id.includes("a-");
isMAL = id.includes("m-");
isSimkl = id.includes("s-");
if (isAniList || isMAL || isSimkl) newId = id.match(re)[1];
else newId = id;
}
if (isAniList) url = `https://anilist.co/anime/${newId}`;
if (isMAL) url = `https://myanimelist.net/anime/${newId}`;
if (isSimkl) url = `https://simkl.com/anime/${newId}`;
</script>
{#if url.length > 0}
<button
type="button"
class="underline underline-offset-2 px-4 py-1"
on:click={() => BrowserOpenURL(url)}>{newId}</button
>
{:else}
{id}
{/if}