Skip to content

fix: logo image quality #646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/api/client/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ const queryAPI = async <Query, Variables extends AnyVariables = AnyVariables>({
fetchOptions?: RequestInit;
previewToken?: string;
}): Promise<OperationResult<Query, Variables>> => {
const defaultFetchOptions = {
const defaultFetchOptions: RequestInit = {
cache: "force-cache",
next: {
revalidate: previewToken ? 0 : undefined,
},
};
const fetchOptions = merge({}, defaultFetchOptions, inputFetchOptions);

if (inputFetchOptions?.next?.revalidate) {
delete fetchOptions.cache;
}

const params = new URLSearchParams({});

if (previewToken) {
Expand Down
14 changes: 9 additions & 5 deletions lib/api/globals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ export async function getLogos() {
... on siteInfo_GlobalSet {
logoLarge {
url {
directUrlPreview
directUrlOriginal
}
width
height
}
logoSmall {
url {
directUrlPreview
directUrlOriginal
}
width
height
Expand All @@ -41,7 +41,9 @@ export async function getLogos() {
const { data } = await queryAPI({
query,
variables: { set: "siteInfo" },
fetchOptions: { next: { tags: [tags.globals], revalidate: 60 * 60 } },
fetchOptions: {
next: { tags: [tags.globals], revalidate: 60 * 60 },
},
});

if (!data || !data.siteInfo) {
Expand All @@ -53,15 +55,17 @@ export async function getLogos() {
} = data;

const { props: large } = getImageProps({
...cantoToImageProps(logoLarge[0], { usePreviewUrl: true }),
...cantoToImageProps(logoLarge[0]),
priority: true,
sizes: "33vw",
quality: 90,
});

if (logoSmall[0]) {
const { props: small } = getImageProps({
...cantoToImageProps(logoSmall[0], { usePreviewUrl: true }),
...cantoToImageProps(logoSmall[0]),
priority: true,
sizes: "100vw",
quality: 90,
});

Expand Down
Loading