From 42a935682aca66d2fd130ae080d28ab2bbaaf11a Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Wed, 13 Sep 2023 14:21:31 -0700
Subject: refactor(updates): rename formatters

---
 src/routes/updates/+page.svelte | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

(limited to 'src/routes/updates/+page.svelte')

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}
-- 
cgit v1.2.3

