Skip to content
This repository has been archived by the owner on Sep 22, 2023. It is now read-only.

Commit

Permalink
Pass image context to createSnippetPages
Browse files Browse the repository at this point in the history
Update createSnippetPages to expect an imageContext (optional).
The imageContext will be used to get dynamically imported images.
  • Loading branch information
Chalarangelo committed Jan 10, 2020
1 parent 3980200 commit 91da094
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/functions/build/createPages/createSnippetPages.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { transformSnippetIndex } from 'functions/utils';
/**
* Creates individual snippet pages.
*/
const createSnippetPages = (snippets, snippetPage, createPage, commonContext) => {
const createSnippetPages = (snippets, snippetPage, createPage, commonContext, imageContext = []) => {
snippets.forEach(snippet => {
const recommendedSnippets = recommendationEngine(snippets, snippet);
createPage({
path: `${snippet.node.slug}`,
component: snippetPage,
context: {
snippet: parseSnippetContext(snippet.node, commonContext.cardTemplate),
snippet: parseSnippetContext(snippet.node, commonContext.cardTemplate, imageContext),
...commonContext,
recommendedSnippets: transformSnippetIndex(recommendedSnippets.slice(0, 3)),
},
Expand Down
2 changes: 1 addition & 1 deletion src/functions/parsers/parseSnippetContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { stripMarkdownFormat } from 'functions/utils';
* unnecessary information that should not be sent to the JSX
* component rendering the snippet.
*/
const parseSnippetContext = (snippet, cardTemplate) => {
const parseSnippetContext = (snippet, cardTemplate, imageContext) => {
let templateProps = {};
switch (cardTemplate) {
case 'blog':
Expand Down

0 comments on commit 91da094

Please sign in to comment.