Skip to content

Commit

Permalink
Add image loader (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
morewings authored Feb 4, 2025
1 parent b2a8c2b commit a35a754
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
16 changes: 16 additions & 0 deletions imageLoader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Custom image loader to replace built-in which doesn't work in export mode
* @see https://nextjs.org/docs/app/building-your-application/deploying/static-exports#image-optimization
*/
export default function cloudinaryLoader({
src,
width,
quality,
}: {
src: string;
width: number;
quality?: number;
}) {
const params = ['f_auto', 'c_limit', `w_${width}`, `q_${quality || 'auto'}`];
return `https://res.cloudinary.com/demo/image/upload/${params.join(',')}${src}`;
}
5 changes: 4 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ module.exports = {
distDir: 'build',
output: 'export',
cleanDistDir: true,
images: {unoptimized: true},
images: {
loader: 'custom',
loaderFile: './imageLoader.ts',
},
// Set to deploy at GitHub pages or other non-index page url
basePath: '/next-card',
// Required to compile vCard
Expand Down
2 changes: 1 addition & 1 deletion src/components/Background/Background.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const getBgValue = (propBg: Config['background'], paramBg?: Config['background']
}
return propBg;
};
//blurry

export const Background: FC<Props> = ({children, background = config.background}) => {
const searchParams = useSearchParams();

Expand Down

0 comments on commit a35a754

Please sign in to comment.