Добавил распознавание ссылок на RSS

This commit is contained in:
Иван Кузьменко 2025-07-19 03:48:03 +03:00
parent a3db23bceb
commit 51c4c024a8

View file

@ -16,7 +16,8 @@ const icons: Record<string, string> = {
'hl.teasanctuary.ru': '/icons/half-life.svg', 'hl.teasanctuary.ru': '/icons/half-life.svg',
'git.teasanctuary.ru': 'devicon-plain:git', 'git.teasanctuary.ru': 'devicon-plain:git',
localhost: '/icons/tea-sanctuary-white.svg', localhost: '/icons/tea-sanctuary-white.svg',
email: 'material-symbols:alternate-email' email: 'material-symbols:alternate-email',
rss: 'material-symbols:rss-feed'
}; };
// Особые случаи, когда одним доменом второго уровня не ограничишься (например, randomtrash.itch.io) // Особые случаи, когда одним доменом второго уровня не ограничишься (например, randomtrash.itch.io)
@ -44,6 +45,8 @@ function getIconFromUrl(url: URL): string | undefined {
const href = url.href; const href = url.href;
if (href.startsWith('mailto:')) if (href.startsWith('mailto:'))
return 'email'; return 'email';
if (href.endsWith('/rss.xml'))
return 'rss';
const hostname = url.hostname; const hostname = url.hostname;
const secondLevel = hostname.match(/(([A-Za-z0-9\-])+\.([A-Za-z0-9\-])+)$/)?.at(0) ?? ''; const secondLevel = hostname.match(/(([A-Za-z0-9\-])+\.([A-Za-z0-9\-])+)$/)?.at(0) ?? '';