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

more caching and error handling

This commit is contained in:
2025-03-24 11:45:48 -04:00
parent 8890c1d08d
commit d3250bd00e
18 changed files with 335 additions and 327 deletions

View File

@ -54,7 +54,7 @@ const Image = async ({ params }: { params: Promise<{ slug: string }> }) => {
const { slug } = await params;
// get the post's title and image filename from its frontmatter
const { title, image: imagePath } = await getFrontMatter(slug);
const frontmatter = await getFrontMatter(slug);
return new ImageResponse(
(
@ -67,7 +67,7 @@ const Image = async ({ params }: { params: Promise<{ slug: string }> }) => {
background: "linear-gradient(0deg, hsla(197, 14%, 57%, 1) 0%, hsla(192, 17%, 94%, 1) 100%)",
}}
>
{imagePath && (
{frontmatter!.image && (
<div
style={{
display: "flex",
@ -78,7 +78,7 @@ const Image = async ({ params }: { params: Promise<{ slug: string }> }) => {
{/* eslint-disable-next-line jsx-a11y/alt-text */}
<img
// @ts-expect-error
src={await getLocalImage(`${POSTS_DIR}/${slug}/${imagePath}`)}
src={await getLocalImage(`${POSTS_DIR}/${slug}/${frontmatter!.image}`)}
style={{ objectFit: "cover", height: "100%", width: "100%" }}
/>
</div>
@ -117,7 +117,7 @@ const Image = async ({ params }: { params: Promise<{ slug: string }> }) => {
color: "#fefefe",
}}
>
{title}
{frontmatter!.title}
</div>
</div>
),