Skip to content

Commit 6dadaae

Browse files
committed
Fix unused.
1 parent 0eddd2c commit 6dadaae

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

astro.config.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import path, { dirname } from "path";
2-
import { fileURLToPath } from "url";
1+
import path from "path";
32
import { defineConfig } from "astro/config";
43
import mdx from "@astrojs/mdx";
54
import sitemap from "@astrojs/sitemap";

src/image.service.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type { LocalImageService, ImageTransform, AstroConfig } from "astro";
1+
import type { LocalImageService, ImageTransform } from "astro";
22

33
type OutputFormat = "avif" | "jpeg" | "jpg" | "png" | "webp";
44

55
const service: LocalImageService = {
6-
getURL(options: ImageTransform, imageConfig: AstroConfig["image"]) {
6+
getURL(options: ImageTransform) {
77
const searchParams = new URLSearchParams();
88
searchParams.append(
99
"href",
@@ -16,7 +16,7 @@ const service: LocalImageService = {
1616
return `/_image/?${searchParams.toString()}`;
1717
},
1818

19-
parseURL(url: URL, imageConfig) {
19+
parseURL(url: URL) {
2020
const params = url.searchParams;
2121
return {
2222
src: params.get("href")!,
@@ -35,8 +35,7 @@ const service: LocalImageService = {
3535
height?: number;
3636
quality?: number;
3737
format?: OutputFormat;
38-
},
39-
imageConfig
38+
}
4039
) {
4140
let buffer = inputBuffer;
4241

@@ -63,13 +62,16 @@ const service: LocalImageService = {
6362

6463
const outputBuffer = await image.toBuffer();
6564

65+
// Convert Buffer to Uint8Array
66+
const uint8Array = Uint8Array.from(outputBuffer);
67+
6668
return {
67-
data: outputBuffer,
68-
format: transform.format ?? "webp",
69+
data: uint8Array,
70+
format: transform.format ?? ("webp" as OutputFormat), // Adjust the format here
6971
};
7072
},
7173

72-
getHTMLAttributes(options, imageConfig) {
74+
getHTMLAttributes(options) {
7375
let targetWidth = options.width;
7476
let targetHeight = options.height;
7577

0 commit comments

Comments
 (0)