@@ -9,6 +9,7 @@ const Substitutions = {
9
9
// Head's meta-tags
10
10
META_FAVICON : '{{__favIcon__}}' ,
11
11
META_DATE : '{{__metaDateGenerated__}}' ,
12
+ META_OG_IMG : '{{__metaOGImage__}}' ,
12
13
THEME_CSS : '{{__theme__}}' ,
13
14
// kickoff the on-page script
14
15
STARTUP_JS : '{{__startup__}}' ,
@@ -34,6 +35,7 @@ function buildRecipeIndex(indexTemplate, { defaultTheme, favicon, outputPath, in
34
35
let lettersIndex = '' ;
35
36
// create list of recipes
36
37
let recipeItems = '' ;
38
+ let ogImgURL = '' ;
37
39
38
40
let prevLetter = '' ;
39
41
@@ -50,6 +52,9 @@ function buildRecipeIndex(indexTemplate, { defaultTheme, favicon, outputPath, in
50
52
}
51
53
52
54
const image = images . find ( i => i . name === name ) ;
55
+ if ( ! ogImgURL && image ) {
56
+ ogImgURL = `images/${ image . fileName } ` ;
57
+ }
53
58
const imgPath = image
54
59
? `images/thumbnails/${ image . name } .jpg`
55
60
: 'images/placeholder.svg' ;
@@ -71,6 +76,7 @@ function buildRecipeIndex(indexTemplate, { defaultTheme, favicon, outputPath, in
71
76
. replace ( Substitutions . META_DATE , `<meta name="date" content="${ new Date ( ) } ">` )
72
77
. replace ( Substitutions . THEME_CSS , `theme-${ defaultTheme } ` )
73
78
. replace ( Substitutions . META_FAVICON , favicon ? `<link rel="icon" type="image/png" href="${ favicon } ">` : '' )
79
+ . replace ( Substitutions . META_OG_IMG , ogImgURL ? `<meta property="og:image" content="${ ogImgURL } ">` : '' )
74
80
. replace ( Substitutions . STARTUP_JS , `recipeIndex.init("${ initialIndexView || 'content' } ")` ) ;
75
81
76
82
writeFileSync ( resolve ( outputPath , 'index.html' ) , prettyHtml ( contents ) , { encoding : 'utf8' } ) ;
0 commit comments