Skip to content

Commit

Permalink
fix: logo image quality (#646)
Browse files Browse the repository at this point in the history
* fix: logo image quality
  • Loading branch information
alexgoff authored Dec 23, 2024
1 parent 1567be4 commit a3249c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
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

0 comments on commit a3249c7

Please sign in to comment.