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

properly import and optimize/cache images in markdown files

This commit is contained in:
2025-03-03 15:56:57 -05:00
parent 36faa6c234
commit ba10742c9b
71 changed files with 685 additions and 1100 deletions

View File

@@ -5,7 +5,7 @@ import pMap from "p-map";
import pMemoize from "p-memoize";
import matter from "gray-matter";
import { formatDate } from "./format-date";
import { metadata as defaultMetadata } from "../../app/layout";
import config from "../config";
// path to directory with .mdx files, relative to project root
const POSTS_DIR = "notes";
@@ -71,8 +71,8 @@ export const getPostData = async (
htmlTitle,
slug,
date: formatDate(data.date), // validate/normalize the date string provided from front matter
permalink: new URL(`/${POSTS_DIR}/${slug}/`, defaultMetadata.metadataBase || "").href,
image: data.image ? new URL(data.image, defaultMetadata.metadataBase || "").href : undefined,
permalink: `${config.baseUrl}/${POSTS_DIR}/${slug}/`,
image: data.image ? `${config.baseUrl}${data.image}` : undefined,
},
markdown: content,
};