Skip to content

Commit 8329d6e

Browse files
committed
fix: Update metafile access in getFileBySlug function
- Changed the way metafile is accessed in the getFileBySlug function to ensure type safety by casting the result to 'any'. - Improved clarity by defining the metafile structure explicitly, enhancing maintainability and reducing potential runtime errors.
1 parent c77ee53 commit 8329d6e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/mdx.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,11 +715,14 @@ export async function getFileBySlug(slug: string): Promise<SlugFile> {
715715

716716
// Map the first image to its hashed output filename using esbuild's metafile
717717
let firstImageHashed: string | undefined;
718-
if (firstImageRef[0] && result.metafile) {
718+
if (firstImageRef[0] && (result as any).metafile) {
719719
const firstImagePath = firstImageRef[0];
720+
const metafile = (result as any).metafile as {
721+
outputs: Record<string, {inputs?: Record<string, any>}>;
722+
};
720723

721724
// Find the output file that corresponds to this input image
722-
for (const [outputPath, outputInfo] of Object.entries(result.metafile.outputs)) {
725+
for (const [outputPath, outputInfo] of Object.entries(metafile.outputs)) {
723726
if (outputInfo.inputs) {
724727
for (const inputPath of Object.keys(outputInfo.inputs)) {
725728
// Check if this input matches our first image

0 commit comments

Comments
 (0)