Compare commits

...

2 Commits

Author SHA1 Message Date
7d7130b23c fix git ignore 2026-01-16 11:59:21 +09:00
2533720014 fix favicon 2026-01-16 11:32:56 +09:00
4 changed files with 12 additions and 9 deletions

1
.gitignore vendored
View File

@@ -3,3 +3,4 @@ dist
node_modules
package-lock.json
repos
CLAUDE.md

View File

@@ -36,14 +36,14 @@ async function renderServices(did: string, handle: string): Promise<string> {
}
// Group by service domain
const serviceMap = new Map<string, { name: string; favicon: string; count: number }>()
const serviceMap = new Map<string, { name: string; favicon: string; faviconFallback: string; count: number }>()
for (const col of collections) {
const info = getServiceInfo(col)
if (info) {
const key = info.domain
if (!serviceMap.has(key)) {
serviceMap.set(key, { name: info.name, favicon: info.favicon, count: 0 })
serviceMap.set(key, { name: info.name, favicon: info.favicon, faviconFallback: info.faviconFallback, count: 0 })
}
serviceMap.get(key)!.count++
}
@@ -53,7 +53,7 @@ async function renderServices(did: string, handle: string): Promise<string> {
return `
<li class="service-list-item">
<a href="/at/${handle}/${domain}" class="service-list-link">
<img src="${info.favicon}" class="service-list-favicon" alt="" onerror="this.style.display='none'">
<img src="${info.favicon}" class="service-list-favicon" alt="" onerror="this.src='${info.faviconFallback}'; this.onerror=null;">
<span class="service-list-name">${info.name}</span>
<span class="service-list-count">${info.count}</span>
</a>

View File

@@ -9,14 +9,14 @@ export async function renderServices(handle: string): Promise<string> {
}
// Group by service
const serviceMap = new Map<string, { name: string; favicon: string; collections: string[] }>()
const serviceMap = new Map<string, { name: string; favicon: string; faviconFallback: string; collections: string[] }>()
for (const col of collections) {
const info = getServiceInfo(col)
if (info) {
const key = info.domain
if (!serviceMap.has(key)) {
serviceMap.set(key, { name: info.name, favicon: info.favicon, collections: [] })
serviceMap.set(key, { name: info.name, favicon: info.favicon, faviconFallback: info.faviconFallback, collections: [] })
}
serviceMap.get(key)!.collections.push(col)
}
@@ -27,7 +27,7 @@ export async function renderServices(handle: string): Promise<string> {
return `
<a href="${url}" class="service-item" title="${info.collections.join(', ')}">
<img src="${info.favicon}" class="service-favicon" alt="" onerror="this.style.display='none'">
<img src="${info.favicon}" class="service-favicon" alt="" onerror="this.src='${info.faviconFallback}'; this.onerror=null;">
<span class="service-name">${info.name}</span>
</a>
`

View File

@@ -307,14 +307,15 @@ export async function searchPostsForUrl(url: string): Promise<any[]> {
return allPosts
}
export function getServiceInfo(collection: string): { name: string; domain: string; favicon: string } | null {
export function getServiceInfo(collection: string): { name: string; domain: string; favicon: string; faviconFallback: string } | null {
// Try to find matching service prefix
for (const [prefix, info] of Object.entries(SERVICE_MAP)) {
if (collection.startsWith(prefix)) {
return {
name: info.domain,
domain: info.domain,
favicon: info.icon || `https://www.google.com/s2/favicons?domain=${info.domain}&sz=32`
favicon: `/favicons/${info.domain}.png`,
faviconFallback: info.icon || `https://www.google.com/s2/favicons?domain=${info.domain}&sz=32`
}
}
}
@@ -326,7 +327,8 @@ export function getServiceInfo(collection: string): { name: string; domain: stri
return {
name: domain,
domain: domain,
favicon: `https://www.google.com/s2/favicons?domain=${domain}&sz=32`
favicon: `/favicons/${domain}.png`,
faviconFallback: `https://www.google.com/s2/favicons?domain=${domain}&sz=32`
}
}