Create 128 * 128 proxy image for the site icon

This commit is contained in:
Hongbo Wu 2022-10-18 12:04:22 +08:00
parent 22e92256eb
commit a7e92addb0
3 changed files with 8 additions and 3 deletions

View file

@ -54,6 +54,7 @@ import { ContentParseError } from '../../utils/errors'
import {
authorized,
generateSlug,
isBase64Image,
isParsingTimeout,
pageError,
stringToHash,
@ -889,6 +890,10 @@ export const searchResolver = authorized<
}
const edges = results.map((r) => {
let siteIcon = r.siteIcon
if (siteIcon && !isBase64Image(siteIcon)) {
siteIcon = createImageProxyUrl(siteIcon, 128, 128)
}
return {
node: {
...r,
@ -900,7 +905,7 @@ export const searchResolver = authorized<
publishedAt: validatedDate(r.publishedAt),
ownedByViewer: r.userId === claims.uid,
pageType: r.pageType || PageType.Highlights,
siteIcon: r.siteIcon && createImageProxyUrl(r.siteIcon, 32, 32),
siteIcon,
} as SearchItem,
cursor: endCursor,
}

View file

@ -60,7 +60,7 @@ export const subscriptionsResolver = authorized<
return {
subscriptions: subscriptions.map((s) => ({
...s,
icon: s.icon && createImageProxyUrl(s.icon, 32, 32),
icon: s.icon && createImageProxyUrl(s.icon, 128, 128),
})),
}
} catch (error) {

View file

@ -442,7 +442,7 @@ export const fetchFavicon = async (
const response = await axios.head(url, { timeout: 5000 })
const realUrl = response.request.res.responseUrl
const domain = new URL(realUrl).hostname
return `https://api.faviconkit.com/${domain}/32`
return `https://api.faviconkit.com/${domain}/128`
} catch (e) {
console.log('Error fetching favicon', e)
return undefined