1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-03 17:26:37 -04:00

fix post title encoding

This commit is contained in:
2025-03-14 15:08:00 -04:00
parent 3932660acc
commit 6e572a8f48
7 changed files with 29 additions and 12 deletions

View File

@ -1,6 +1,6 @@
import Image from "next/image";
import clsx from "clsx";
import Link from "../Link";
import Image from "../Image";
import Menu from "../Menu";
import * as config from "../../lib/config";
import { MAX_WIDTH } from "../../lib/config/constants";

View File

@ -0,0 +1,5 @@
.image {
display: block;
margin: 1em auto;
max-width: 100%;
}

View File

@ -1,11 +1,14 @@
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";
export type ImageProps = ComponentPropsWithoutRef<typeof NextImage>;
const Image = ({ src, height, width, quality, placeholder, style, ...rest }: ImageProps) => {
const Image = ({ src, height, width, placeholder, className, ...rest }: ImageProps) => {
const constrainWidth = (width?: number | `${number}`) => {
if (!width) return MAX_WIDTH;
@ -16,16 +19,11 @@ const Image = ({ src, height, width, quality, placeholder, style, ...rest }: Ima
src,
height,
width: constrainWidth(width || (src as StaticImageData).width),
quality: quality || 75,
placeholder: placeholder || (typeof src === "string" ? "empty" : "blur"),
style: {
height: "auto",
...style,
},
...rest,
};
return <NextImage {...imageProps} />;
return <NextImage className={clsx(styles.image, className)} {...imageProps} />;
};
export default Image;