diff options
| author | Fuwn <[email protected]> | 2023-09-13 14:21:31 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-09-13 14:21:31 -0700 |
| commit | 42a935682aca66d2fd130ae080d28ab2bbaaf11a (patch) | |
| tree | e0e45d499797d56c5731c6966ba1af30ddc4cd16 /src | |
| parent | feat(updates): italic titles (diff) | |
| download | due.moe-42a935682aca66d2fd130ae080d28ab2bbaaf11a.tar.xz due.moe-42a935682aca66d2fd130ae080d28ab2bbaaf11a.zip | |
refactor(updates): rename formatters
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/updates/+page.svelte | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/routes/updates/+page.svelte b/src/routes/updates/+page.svelte index 2a9333ab..26af53bc 100644 --- a/src/routes/updates/+page.svelte +++ b/src/routes/updates/+page.svelte @@ -20,21 +20,19 @@ mangaEndTime = performance.now() - startTime; }); - const reformat = (title: string) => { - return title + const reformatChapter = (title: string) => + title .replace(/\[.*?\]\s/, '') .replace(/c\.Oneshot/, 'Oneshot') .replace(/c\.(\d+-\d+)/, 'Ch. $1') .replace(/v\.(\d+)\s/, 'Vol. $1 ') .replace(/c\.(\d+)/, 'Ch. $1'); - }; - function reformatChapters(title: string): string { - return title + const clipTitle = (title: string): string => + title .replace(/(Vol\. \d+ )?Ch\. \d+(-\d+(\.\d+)?)?$/, '') .replace(/\? ~.*$/, '') .trim(); - } const italicTitle = (title: string) => title.replace(/^(.*?) Ch\.|\bOneshot\b/, '<i>$1</i> Ch.'); </script> @@ -54,16 +52,16 @@ {#each feed.items as item} <li> {#if directLink} - <i>{reformat(item.title)}</i> + <i>{reformatChapter(item.title)}</i> {@html item.content} {:else} <a - href={`https://anilist.co/search/manga?search=${reformatChapters( - reformat(item.title) + href={`https://anilist.co/search/manga?search=${clipTitle( + reformatChapter(item.title) )}&sort=SEARCH_MATCH`} > - {@html italicTitle(reformat(item.title))} + {@html italicTitle(reformatChapter(item.title))} </a> {/if} </li> @@ -89,7 +87,7 @@ {#each novelFeed.items as item} <li> <a href={item.link}> - {reformat(item.title)} + {reformatChapter(item.title)} </a> </li> {/each} |