Skip to content

Commit

Permalink
Merge pull request #4 from buzcarter/feature/index_OG_image
Browse files Browse the repository at this point in the history
quick hack it in.
  • Loading branch information
buzcarter authored Oct 23, 2023
2 parents 724e8de + 3d4f1b5 commit 9e5ac01
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/buildRecipeIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Substitutions = {
// Head's meta-tags
META_FAVICON: '{{__favIcon__}}',
META_DATE: '{{__metaDateGenerated__}}',
META_OG_IMG: '{{__metaOGImage__}}',
THEME_CSS: '{{__theme__}}',
// kickoff the on-page script
STARTUP_JS: '{{__startup__}}',
Expand All @@ -34,6 +35,7 @@ function buildRecipeIndex(indexTemplate, { defaultTheme, favicon, outputPath, in
let lettersIndex = '';
// create list of recipes
let recipeItems = '';
let ogImgURL = '';

let prevLetter = '';

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

const image = images.find(i => i.name === name);
if (!ogImgURL && image) {
ogImgURL = `images/${image.fileName}`;
}
const imgPath = image
? `images/thumbnails/${image.name}.jpg`
: 'images/placeholder.svg';
Expand All @@ -71,6 +76,7 @@ function buildRecipeIndex(indexTemplate, { defaultTheme, favicon, outputPath, in
.replace(Substitutions.META_DATE, `<meta name="date" content="${new Date()}">`)
.replace(Substitutions.THEME_CSS, `theme-${defaultTheme}`)
.replace(Substitutions.META_FAVICON, favicon ? `<link rel="icon" type="image/png" href="${favicon}">` : '')
.replace(Substitutions.META_OG_IMG, ogImgURL ? `<meta property="og:image" content="${ogImgURL}">` : '')
.replace(Substitutions.STARTUP_JS, `recipeIndex.init("${initialIndexView || 'content'}")`);

writeFileSync(resolve(outputPath, 'index.html'), prettyHtml(contents), { encoding: 'utf8' });
Expand Down
1 change: 1 addition & 0 deletions src/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<!-- basics -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
{{__metaOGImage__}}
{{__metaDateGenerated__}}
{{__favIcon__}}
<!-- font and styles -->
Expand Down

0 comments on commit 9e5ac01

Please sign in to comment.