Skip to content

Commit

Permalink
fix: Favicon sizes conform to Google Search guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
istarkov committed Jun 10, 2024
1 parent 85f0309 commit d733cd3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
17 changes: 4 additions & 13 deletions packages/cli/templates/defaults/app/route-templates/html.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,24 +186,15 @@ export const links: LinksFunction = () => {
rel: "icon",
href: imageLoader({
src: favIconAsset.name,
width: 128,
// width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
width: 144,
height: 144,
fit: "pad",
quality: 100,
format: "auto",
}),
type: undefined,
});
} else {
result.push({
rel: "icon",
href: "/favicon.ico",
type: "image/x-icon",
});

result.push({
rel: "shortcut icon",
href: "/favicon.ico",
type: "image/x-icon",
});
}

for (const asset of pageFontAssets) {
Expand Down
8 changes: 8 additions & 0 deletions packages/image/src/image-loaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ export const createImageLoader =
searchParams.set("quality", quality.toString());
searchParams.set("format", format ?? "auto");

if (props.format !== "raw" && props.height != null) {
searchParams.set("height", props.height.toString());
}

if (props.format !== "raw" && props.fit != null) {
searchParams.set("height", props.fit);
}

// Cloudflare docs say that we don't need to urlencode the path params
return `${imageBaseUrl}${src}?${searchParams.toString()}`;
};
2 changes: 2 additions & 0 deletions packages/image/src/image-optimize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export type ImageLoader = (
quality: number;
src: string;
format?: "auto";
height?: number;
fit?: "pad";
}
| { src: string; format: "raw" }
) => string;
Expand Down

0 comments on commit d733cd3

Please sign in to comment.