@@ -2,26 +2,24 @@ const { join } = require("path");
2
2
const { config } = require ( "./src/config" ) ;
3
3
4
4
exports . createOpenGraphImage = ( createPage , options ) => {
5
- config . init ( options )
6
- const { defaultSize, componentGenerationDir, defaultWaitCondition } = config . getConfig ( ) ;
7
- const { path, component, context } = options ;
5
+ config . init ( options ) ;
8
6
9
- const size = { ...defaultSize , ...( options . size || { } ) } ;
10
- const waitCondition = options . waitCondition ? options . waitCondition : defaultWaitCondition ;
11
- const componentPath = join ( componentGenerationDir , encodeURIComponent ( path . split ( "/" ) . join ( "" ) ) ) ;
12
- const imgPath = join ( "public" , path ) ;
7
+ const { size, componentGenerationDir } = config . getConfig ( ) ;
8
+ const { component, context } = options ;
13
9
14
- const generationContext = { componentPath, imgPath, size, waitCondition } ;
15
- const ogImageMetaData = { path, size, __ogImageGenerationContext : generationContext } ;
10
+ const componentPath = `${ componentGenerationDir } /${ context . id } ` ;
11
+ const imagePath = join ( "public" , componentGenerationDir , `${ context . id } .png` ) ;
12
+
13
+ const ogImageMetadata = { componentPath, imagePath, size } ;
16
14
17
15
createPage ( {
18
16
path : componentPath ,
19
- component : component ,
17
+ component,
20
18
context : {
21
19
...context ,
22
- ogImage : ogImageMetaData ,
20
+ ogImage : ogImageMetadata ,
23
21
} ,
24
22
} ) ;
25
23
26
- return ogImageMetaData ;
24
+ return ogImageMetadata ;
27
25
} ;
0 commit comments