1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2026-05-15 20:54:28 -04:00

pre-render optimizations

This commit is contained in:
2025-03-14 12:51:18 -04:00
parent e162d6a46c
commit 3932660acc
57 changed files with 305 additions and 318 deletions
-5
View File
@@ -1,5 +0,0 @@
.image {
height: auto;
max-width: 100%;
border-radius: var(--radii-corner);
}
+7 -7
View File
@@ -1,15 +1,11 @@
import NextImage from "next/image";
import clsx from "clsx";
import { MAX_WIDTH } from "../../lib/config/constants";
import type { ComponentPropsWithoutRef } from "react";
import type { StaticImageData } from "next/image";
import styles from "./Image.module.css";
const MAX_WIDTH = 865;
export type ImageProps = ComponentPropsWithoutRef<typeof NextImage>;
const Image = ({ src, height, width, quality, placeholder, className, ...rest }: ImageProps) => {
const Image = ({ src, height, width, quality, placeholder, style, ...rest }: ImageProps) => {
const constrainWidth = (width?: number | `${number}`) => {
if (!width) return MAX_WIDTH;
@@ -22,10 +18,14 @@ const Image = ({ src, height, width, quality, placeholder, className, ...rest }:
width: constrainWidth(width || (src as StaticImageData).width),
quality: quality || 75,
placeholder: placeholder || (typeof src === "string" ? "empty" : "blur"),
style: {
height: "auto",
...style,
},
...rest,
};
return <NextImage className={clsx(styles.image, className)} {...imageProps} />;
return <NextImage {...imageProps} />;
};
export default Image;