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 node_modules
package-lock.json package-lock.json
repos repos
CLAUDE.md

View File

@@ -36,14 +36,14 @@ async function renderServices(did: string, handle: string): Promise<string> {
} }
// Group by service domain // 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) { for (const col of collections) {
const info = getServiceInfo(col) const info = getServiceInfo(col)
if (info) { if (info) {
const key = info.domain const key = info.domain
if (!serviceMap.has(key)) { 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++ serviceMap.get(key)!.count++
} }
@@ -53,7 +53,7 @@ async function renderServices(did: string, handle: string): Promise<string> {
return ` return `
<li class="service-list-item"> <li class="service-list-item">
<a href="/at/${handle}/${domain}" class="service-list-link"> <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-name">${info.name}</span>
<span class="service-list-count">${info.count}</span> <span class="service-list-count">${info.count}</span>
</a> </a>

View File

@@ -9,14 +9,14 @@ export async function renderServices(handle: string): Promise<string> {
} }
// Group by service // 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) { for (const col of collections) {
const info = getServiceInfo(col) const info = getServiceInfo(col)
if (info) { if (info) {
const key = info.domain const key = info.domain
if (!serviceMap.has(key)) { 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) serviceMap.get(key)!.collections.push(col)
} }
@@ -27,7 +27,7 @@ export async function renderServices(handle: string): Promise<string> {
return ` return `
<a href="${url}" class="service-item" title="${info.collections.join(', ')}"> <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> <span class="service-name">${info.name}</span>
</a> </a>
` `

View File

@@ -307,14 +307,15 @@ export async function searchPostsForUrl(url: string): Promise<any[]> {
return allPosts 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 // Try to find matching service prefix
for (const [prefix, info] of Object.entries(SERVICE_MAP)) { for (const [prefix, info] of Object.entries(SERVICE_MAP)) {
if (collection.startsWith(prefix)) { if (collection.startsWith(prefix)) {
return { return {
name: info.domain, name: info.domain,
domain: 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 { return {
name: domain, name: domain,
domain: 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`
} }
} }