diff options
| author | Fuwn <[email protected]> | 2023-12-07 03:15:28 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-12-07 03:15:28 -0800 |
| commit | 31fcf3e18911f55acd43cfc28f3bde368f20a255 (patch) | |
| tree | c55745213d0fa49f045ebeb18003904bee7f0198 /src/lib/Media | |
| parent | fix(app): types for bun (diff) | |
| download | due.moe-31fcf3e18911f55acd43cfc28f3bde368f20a255.tar.xz due.moe-31fcf3e18911f55acd43cfc28f3bde368f20a255.zip | |
feat(media): outbound links option
Diffstat (limited to 'src/lib/Media')
| -rw-r--r-- | src/lib/Media/media.ts | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/lib/Media/media.ts b/src/lib/Media/media.ts new file mode 100644 index 00000000..a98d5d07 --- /dev/null +++ b/src/lib/Media/media.ts @@ -0,0 +1,42 @@ +import type { Media } from '$lib/AniList/media'; + +export const outboundLink = ( + media: Media, + type: 'anime' | 'manga', + setting: 'anilist' | 'livechartme' | 'animeschedule' | 'myanimelist' +) => { + if (type === 'manga') { + switch (setting) { + case 'livechartme': + case 'animeschedule': + return `https://anilist.co/${type}/${media.id}`; + case 'myanimelist': + return `https://myanimelist.net/search/all?q=${ + media.title.native || media.title.english || media.title.romaji + }`; + default: + return `https://anilist.co/${type}/${media.id}`; + } + } else { + switch (setting) { + case 'anilist': + return `https://anilist.co/${type}/${media.id}`; + case 'livechartme': + return `https://www.livechart.me/search?q=${( + media.title.native || + media.title.english || + media.title.romaji + ).replace(/ /g, '+')}`; + case 'animeschedule': + return `https://animeschedule.net/shows?q=${( + media.title.native || + media.title.english || + media.title.romaji + ).replace(/ /g, '+')}`; + case 'myanimelist': + return `https://myanimelist.net/search/all?q=${ + media.title.native || media.title.english || media.title.romaji + }`; + } + } +}; |