Skip to content

Commit 499d2c7

Browse files
committed
style: apply prettier formatting
1 parent 5526dff commit 499d2c7

2 files changed

Lines changed: 43 additions & 16 deletions

File tree

src/components/Header.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ export const Header = () => {
4141
>
4242
<PaperAirplaneIcon />
4343
</button>
44-
<Link className="iconButton" href="/rss" title="RSS feeds" aria-label="RSS feeds">
44+
<Link
45+
className="iconButton"
46+
href="/rss"
47+
title="RSS feeds"
48+
aria-label="RSS feeds"
49+
>
4550
<RssIcon />
4651
</Link>
4752
<a

src/lib/hnrss.ts

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ const xmlEscape = (value: string) =>
8888
.replaceAll('"', "&quot;")
8989
.replaceAll("'", "&apos;");
9090

91-
const cdata = (value: string) => `<![CDATA[${value.replaceAll("]]>", "]]]]><![CDATA[>")}]]>`;
91+
const cdata = (value: string) =>
92+
`<![CDATA[${value.replaceAll("]]>", "]]]]><![CDATA[>")}]]>`;
9293

9394
const formatUTC = (date: Date) => date.toUTCString().replace("GMT", "+0000");
9495

@@ -162,7 +163,8 @@ const rewriteHackerNewsHref = (href: string, origin: string) => {
162163
}
163164
};
164165

165-
const HN_TEXT_URL_REGEXP = /https?:\/\/news\.ycombinator\.com\S+|news\.ycombinator\.com\S+/g;
166+
const HN_TEXT_URL_REGEXP =
167+
/https?:\/\/news\.ycombinator\.com\S+|news\.ycombinator\.com\S+/g;
166168

167169
const rewriteHackerNewsText = (text: string, origin: string) =>
168170
text.replace(HN_TEXT_URL_REGEXP, (match) => {
@@ -263,7 +265,10 @@ const buildStrongUserLink = (origin: string, author: string) =>
263265

264266
const wrapBracketLinksLine = (links: Array<{ href: string; label: string }>) =>
265267
`<p>${links
266-
.map(({ href, label }) => `<a href="${escapeHtml(href)}">${escapeHtml(label)}</a>`)
268+
.map(
269+
({ href, label }) =>
270+
`<a href="${escapeHtml(href)}">${escapeHtml(label)}</a>`,
271+
)
267272
.map((link) => `[${link}]`)
268273
.join(" ")}</p>`;
269274

@@ -304,7 +309,9 @@ export const parseRSSQuery = (
304309
const linkTo = isStoryFeed && link === "comments" ? "comments" : "article";
305310
const descriptionMode = parseDescriptionMode(query.description);
306311
const minPoints = isStoryFeed ? parsePositiveInt(query.points) : undefined;
307-
const minComments = isStoryFeed ? parsePositiveInt(query.comments) : undefined;
312+
const minComments = isStoryFeed
313+
? parsePositiveInt(query.comments)
314+
: undefined;
308315

309316
return {
310317
count: clampCount(count),
@@ -349,7 +356,9 @@ const fetchJSON = async <T>(url: string) => {
349356
const fetchAlgolia = async (params: URLSearchParams) => {
350357
const url = `${ALGOLIA_SEARCH_URL}?${params.toString()}`;
351358

352-
const response = await getCached(url, () => fetchJSON<AlgoliaSearchResponse>(url));
359+
const response = await getCached(url, () =>
360+
fetchJSON<AlgoliaSearchResponse>(url),
361+
);
353362

354363
return response.hits ?? [];
355364
};
@@ -372,14 +381,16 @@ const parseScrapedPage = (html: string) => {
372381
.querySelectorAll("tr.athing")
373382
.map((node) => node.getAttribute("id"))
374383
.filter((id): id is string => Boolean(id)),
375-
nextPath: document.querySelector("a.morelink")?.getAttribute("href") ?? undefined,
384+
nextPath:
385+
document.querySelector("a.morelink")?.getAttribute("href") ?? undefined,
376386
};
377387
};
378388

379389
const scrapePage = async (path: string, page?: number) => {
380-
const url = page === undefined
381-
? new URL(path, HN_BASE_URL).toString()
382-
: buildPaginatedHNUrl(path, page);
390+
const url =
391+
page === undefined
392+
? new URL(path, HN_BASE_URL).toString()
393+
: buildPaginatedHNUrl(path, page);
383394
const html = await getCached(url, () => fetchText(url));
384395

385396
return parseScrapedPage(html);
@@ -432,7 +443,10 @@ const buildSpecialFeedParams = (
432443
if (feed.source === "comments") {
433444
params.set("filters", ids.map((id) => `objectID:"${id}"`).join(" OR "));
434445
} else {
435-
params.set("tags", `(story,poll),(${ids.map((id) => `story_${id}`).join(",")})`);
446+
params.set(
447+
"tags",
448+
`(story,poll),(${ids.map((id) => `story_${id}`).join(",")})`,
449+
);
436450
}
437451

438452
return params;
@@ -585,7 +599,9 @@ const buildStoryDescription = (
585599
`<p>Points: <strong>${escapeHtml(formatCompactNumber(hit.points ?? 0))}</strong> | Comments: <strong>${escapeHtml(formatCount(hit.num_comments ?? 0))}</strong> | submitted by ${buildStrongUserLink(origin, hit.author)}</p>`,
586600
);
587601

588-
descriptionParts.push(buildDescriptionLinksLine(commentsUrl, "comments", articleUrl));
602+
descriptionParts.push(
603+
buildDescriptionLinksLine(commentsUrl, "comments", articleUrl),
604+
);
589605
appendDescriptionBody(descriptionParts, query.descriptionMode, storyText);
590606

591607
return descriptionParts.join("\n");
@@ -619,7 +635,9 @@ const buildCommentDescription = (
619635
`<p>submitted by ${buildStrongUserLink(origin, hit.author)}</p>`,
620636
);
621637

622-
descriptionParts.push(buildDescriptionLinksLine(commentUrl, "comment", storyUrl));
638+
descriptionParts.push(
639+
buildDescriptionLinksLine(commentUrl, "comment", storyUrl),
640+
);
623641
appendDescriptionBody(descriptionParts, query.descriptionMode, commentText);
624642

625643
return descriptionParts.join("\n");
@@ -670,7 +688,8 @@ const buildCommentItem = (
670688
};
671689
};
672690

673-
const buildChannelTitle = (feed: RSSFeedDefinition) => `Hacker News: ${feed.title}`;
691+
const buildChannelTitle = (feed: RSSFeedDefinition) =>
692+
`Hacker News: ${feed.title}`;
674693

675694
const buildItemDescriptionXML = (description?: string) => {
676695
if (!description) {
@@ -687,8 +706,11 @@ export const buildRSSFeedXML = async (
687706
) => {
688707
const hits = await getAlgoliaHits(feed, query);
689708
const visibleHits = hits.slice(0, query.count);
690-
const buildItem = feed.source === "comments" ? buildCommentItem : buildStoryItem;
691-
const items = visibleHits.map((hit) => buildItem(hit, requestUrl.origin, query));
709+
const buildItem =
710+
feed.source === "comments" ? buildCommentItem : buildStoryItem;
711+
const items = visibleHits.map((hit) =>
712+
buildItem(hit, requestUrl.origin, query),
713+
);
692714

693715
const lastBuildDate = toRSSDate(new Date());
694716
const docsUrl = `${requestUrl.origin}/rss`;

0 commit comments

Comments
 (0)