forked from 0x2E/fusion
feat: add support for buttondown.com favicon
This commit is contained in:
parent
47b113176c
commit
34b3c33cb3
1 changed files with 20 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue