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:
@ -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";
|
||||
|
5
components/Image/Image.module.css
Normal file
5
components/Image/Image.module.css
Normal file
@ -0,0 +1,5 @@
|
||||
.image {
|
||||
display: block;
|
||||
margin: 1em auto;
|
||||
max-width: 100%;
|
||||
}
|
@ -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;
|
||||
|
Reference in New Issue
Block a user