From cec9c88e84b54c51091be812c3f1ed9ca8b0e2ed Mon Sep 17 00:00:00 2001 From: haochengxu Date: Sun, 24 Sep 2023 20:34:04 +0800 Subject: [PATCH] updat image loader --- image-loader.ts | 12 ++++++++++++ next.config.js | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 image-loader.ts diff --git a/image-loader.ts b/image-loader.ts new file mode 100644 index 0000000..91b477f --- /dev/null +++ b/image-loader.ts @@ -0,0 +1,12 @@ +export default function imageLoader({ + src, + width, + quality, + }: { + src: string + width: number + quality?: number + }) { + // const params = ['f_auto', 'c_limit', `w_${width}`, `q_${quality || 'auto'}`] + return src.startsWith('/') ? src.substring(1) : `${src}` + } \ No newline at end of file diff --git a/next.config.js b/next.config.js index 66a08a8..5007e27 100644 --- a/next.config.js +++ b/next.config.js @@ -4,9 +4,9 @@ const nextConfig = { output: 'export', images: { - unoptimized: true, - basePath: '', - } + loader: 'custom', + loaderFile: './image-loader.ts', + }, // Optional: Change links `/me` -> `/me/` and emit `/me.html` -> `/me/index.html` // trailingSlash: true,