Skip to content

Commit d0bf6f4

Browse files
committed
Add checks to model parameters in writeFile
1 parent d3ae33b commit d0bf6f4

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,14 @@ module.exports.getOptionsFromSetup = ({ answers, debug }) => {
8686
page.layoutSource ? "layout" : null,
8787
"...frontmatterFields"
8888
];
89+
const conditionParts = [
90+
modelName && `modelName === '${modelName}'`,
91+
projectId && `projectId === '${projectId}'`,
92+
source && `source === '${source}'`
93+
].filter(Boolean);
8994

9095
conditions.push(
91-
`if (modelName === '${modelName}' && projectId === '${projectId}' && source === '${source}') {`,
96+
`if (${conditionParts.join(" && ")}) {`,
9297
` const { ${extractedProperties.filter(Boolean).join(", ")} } = entry;`,
9398
``,
9499
` return {`,

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sourcebit-target-hugo",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "A Sourcebit plugin for Hugo",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)