-
Notifications
You must be signed in to change notification settings - Fork 0
/
sites.ts
23 lines (19 loc) 路 829 Bytes
/
sites.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import type { site } from "../types/mod.ts";
const sites: site[] = [
{ type: "bluesky", url: new URL("https://bsky.app/profile/{id}/rss") },
{ type: "note", url: new URL("https://note.com/{id}/rss") },
{ type: "reddit", url: new URL("https://www.reddit.com/r/{id}/.rss") },
{ type: "sizu.me", url: new URL("https://sizu.me/{id}/rss") },
];
export function transcodeXmlUrl(
title: string,
type: string | undefined,
id: string | undefined,
): URL {
if (!type) throw new Error(`Parameter not set: "type" of "${title}"`);
if (!id) throw new Error(`Parameter not set: "id" of "${title}"`);
const url: URL | undefined = sites
.find((site: site) => site.type === type)?.url;
if (!url) throw new Error(`Site not found: "${type}" of "${title}"`);
return new URL(url.href.replace(encodeURI("{id}"), id));
}