1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-17 18:45:32 -04:00

dynamic opengraph images

This commit is contained in:
2025-03-14 08:22:32 -04:00
parent 4d2febd262
commit e162d6a46c
35 changed files with 310 additions and 208 deletions

View File

@@ -15,13 +15,17 @@ export type FrontMatter = {
title: string;
htmlTitle?: string;
description?: string;
image?: string;
tags?: string[];
image?: string;
noComments?: boolean;
};
// returns front matter and the **raw & uncompiled** markdown of a given slug
export const getFrontMatter = async (slug: string): Promise<FrontMatter> => {
if (!(await getPostSlugs()).includes(slug)) {
throw new Error(`No post found for slug: ${slug}`);
}
const { frontmatter } = await import(`../../${POSTS_DIR}/${slug}/index.mdx`);
const { unified } = await import("unified");
@@ -62,7 +66,6 @@ export const getFrontMatter = async (slug: string): Promise<FrontMatter> => {
slug,
date: formatDate(frontmatter.date), // validate/normalize the date string provided from front matter
permalink: `${config.baseUrl}/${POSTS_DIR}/${slug}`,
image: frontmatter.image ? `${config.baseUrl}${frontmatter.image}` : undefined,
};
};