1
0
Fork 0
forked from 0x2E/fusion

feat: add support for buttondown.com favicon

This commit is contained in:
Kim, Jimin 2025-05-24 11:15:36 +09:00
parent 47b113176c
commit 34b3c33cb3
Signed by: pomp
GPG key ID: D3932F82A0667A3B

View file

@ -1,6 +1,6 @@
/**
* RSSHub paths mapped to their respective hostname.
* Sorted by hostname first then by RSSHub path.
* Sorted by hostname first then by pathname.
*/
const rssHubMap = {
'/papers/category/arxiv': 'arxiv.org',
@ -16,18 +16,36 @@ const rssHubMap = {
'/youtube': 'youtube.com'
};
/**
* Buttondown.com paths mapped to their respective hostname.
* Sorted by hostname first then by pathname.
*/
const buttondownMap = {
'/denonews/': 'deno.news'
};
export function getFavicon(feedLink: string): string {
const url = new URL(feedLink);
let hostname = url.hostname;
let pathname = url.pathname;
if (hostname.includes('rsshub')) {
for (const prefix in rssHubMap) {
if (url.pathname.startsWith(prefix)) {
if (pathname.startsWith(prefix)) {
hostname = rssHubMap[prefix as keyof typeof rssHubMap];
break;
}
}
}
if (hostname === 'buttondown.com') {
for (const prefix in buttondownMap) {
if (pathname.startsWith(prefix)) {
hostname = buttondownMap[prefix as keyof typeof buttondownMap];
break;
}
}
}
return 'https://www.google.com/s2/favicons?sz=32&domain=' + hostname;
}