1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-03 15:16:40 -04:00

do not double import site-wide opengraph-image.jpg

This commit is contained in:
2025-04-11 14:22:06 -04:00
parent 4cb6ed82ee
commit 0ade75716e
9 changed files with 108 additions and 239 deletions

BIN
app/avatar.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@ -17,8 +17,6 @@ import "./themes.css";
import styles from "./layout.module.css";
import ogImage from "./opengraph-image.jpg";
export const metadata: Metadata = defaultMetadata;
const RootLayout = ({ children }: Readonly<{ children: React.ReactNode }>) => {
@ -34,12 +32,7 @@ const RootLayout = ({ children }: Readonly<{ children: React.ReactNode }>) => {
"@id": `${BASE_URL}/#person`,
name: config.authorName,
url: BASE_URL,
image: {
"@type": "ImageObject",
contentUrl: `${BASE_URL}${ogImage.src}`,
width: `${ogImage.width}`,
height: `${ogImage.height}`,
},
image: [`${BASE_URL}/opengraph-image.jpg`],
sameAs: [
`${BASE_URL}`,
`https://${config.authorSocial?.mastodon}`,

View File

@ -42,13 +42,14 @@ const getLocalImage = async (src: string): Promise<ArrayBuffer | string> => {
// return the raw image data as a buffer
return Uint8Array.from(await readFile(imagePath)).buffer;
} catch (error) {
// fail silently and return a 1x1 transparent gif instead of crashing
console.error(`[og-image] found "${imagePath}" but couldn't read it:`, error);
// fail silently and return a 1x1 transparent gif instead of crashing
return NO_IMAGE;
}
};
const Image = async ({ params }: { params: Promise<{ slug: string }> }) => {
const OpenGraphImage = async ({ params }: { params: Promise<{ slug: string }> }) => {
try {
const { slug } = await params;
@ -233,4 +234,4 @@ const Image = async ({ params }: { params: Promise<{ slug: string }> }) => {
}
};
export default Image;
export default OpenGraphImage;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB