Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c27ff21

Browse files
authoredJul 12, 2022
Merge f3b2feb into 334dc40
2 parents 334dc40 + f3b2feb commit c27ff21

File tree

1 file changed

+6
-1
lines changed
  • plugin/src/templates/edge

1 file changed

+6
-1
lines changed
 

‎plugin/src/templates/edge/ipx.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { Accepts } from "https://deno.land/x/accepts@2.1.1/mod.ts";
22
import type { Context } from "netlify:edge";
3+
// Available at build time
34
import imageconfig from "../functions-internal/_ipx/imageconfig.json" assert {
45
type: "json",
56
};
67

78
const defaultFormat = "webp"
89

10+
interface ImageConfig extends Record<string, unknown> {
11+
formats?: string[];
12+
}
13+
914
/**
1015
* Implement content negotiation for images
1116
*/
@@ -14,7 +19,7 @@ const defaultFormat = "webp"
1419
const handler = async (req: Request, context: Context) => {
1520
const { searchParams } = new URL(req.url);
1621
const accept = new Accepts(req.headers);
17-
const { formats = [defaultFormat] } = imageconfig;
22+
const { formats = [defaultFormat] } = imageconfig as ImageConfig;
1823
if (formats.length === 0) {
1924
formats.push(defaultFormat);
2025
}

0 commit comments

Comments
 (0)
Please sign in to comment.