Skip to content

Commit 3d4f1b5

Browse files
committed
quick hack it in.
1 parent 724e8de commit 3d4f1b5

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/buildRecipeIndex.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const Substitutions = {
99
// Head's meta-tags
1010
META_FAVICON: '{{__favIcon__}}',
1111
META_DATE: '{{__metaDateGenerated__}}',
12+
META_OG_IMG: '{{__metaOGImage__}}',
1213
THEME_CSS: '{{__theme__}}',
1314
// kickoff the on-page script
1415
STARTUP_JS: '{{__startup__}}',
@@ -34,6 +35,7 @@ function buildRecipeIndex(indexTemplate, { defaultTheme, favicon, outputPath, in
3435
let lettersIndex = '';
3536
// create list of recipes
3637
let recipeItems = '';
38+
let ogImgURL = '';
3739

3840
let prevLetter = '';
3941

@@ -50,6 +52,9 @@ function buildRecipeIndex(indexTemplate, { defaultTheme, favicon, outputPath, in
5052
}
5153

5254
const image = images.find(i => i.name === name);
55+
if (!ogImgURL && image) {
56+
ogImgURL = `images/${image.fileName}`;
57+
}
5358
const imgPath = image
5459
? `images/thumbnails/${image.name}.jpg`
5560
: 'images/placeholder.svg';
@@ -71,6 +76,7 @@ function buildRecipeIndex(indexTemplate, { defaultTheme, favicon, outputPath, in
7176
.replace(Substitutions.META_DATE, `<meta name="date" content="${new Date()}">`)
7277
.replace(Substitutions.THEME_CSS, `theme-${defaultTheme}`)
7378
.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}">` : '')
7480
.replace(Substitutions.STARTUP_JS, `recipeIndex.init("${initialIndexView || 'content'}")`);
7581

7682
writeFileSync(resolve(outputPath, 'index.html'), prettyHtml(contents), { encoding: 'utf8' });

src/templates/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<!-- basics -->
77
<meta charset="utf-8" />
88
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
9+
{{__metaOGImage__}}
910
{{__metaDateGenerated__}}
1011
{{__favIcon__}}
1112
<!-- font and styles -->

0 commit comments

Comments
 (0)