Skip to content

Commit 92fcc67

Browse files
committed
refactor: Update SlugFile type definition to include optional firstImage field
- Moved the firstImage property to the end of the SlugFile type definition for better organization. - Updated the remarkExtractFirstImage function to return undefined when no image is found, improving clarity in the image extraction logic.
1 parent 71a9108 commit 92fcc67

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/mdx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ import {isNotNil} from './utils';
4545
import {isVersioned, VERSION_INDICATOR} from './versioning';
4646

4747
type SlugFile = {
48-
firstImage?: string;
4948
frontMatter: Platform & {slug: string};
5049
matter: Omit<matter.GrayMatterFile<string>, 'data'> & {
5150
data: Platform;
5251
};
5352
mdxSource: string;
5453
toc: TocNode[];
54+
firstImage?: string;
5555
};
5656

5757
const root = process.cwd();

src/remark-extract-first-image.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default function remarkExtractFirstImage(options: {exportRef: string[]})
2525
firstImage = node.url;
2626
return false; // Stop visiting once we find the first image
2727
}
28+
return undefined;
2829
});
2930

3031
// Export the first image URL if found

0 commit comments

Comments
 (0)