Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
Get a test to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
ptgott committed Oct 8, 2024
1 parent 3d20a77 commit cf9b87c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions server/remark-includes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,21 @@ const resolveIncludes = ({
content = content.replace(varRegexp, finalVal);
}

// Catch unresolved parameters, which can break docs builds
const paramRE = new RegExp(`{{ ?\w+ ?}}`, "g");
const unresolvedParams = Array.from(content.matchAll(paramRE));
if (unresolvedParams.length > 0) {
const errs = unresolvedParams
.map((el) => {
return el[0];
})
.join(",");

error =
"The following partial parameters were not assigned and have no default value: " +
errs;
}

return content;
} else {
error = `Wrong import path ${includePath} in file ${filePath}.`;
Expand Down
2 changes: 1 addition & 1 deletion uvu-tests/remark-includes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ Suite("Throws an error if a variable is unresolved and has no default", () => {
value,
path: "/content/4.0/docs/pages/filename.mdx",
});
}, "is not assigned and has no default value");
}, "not assigned and have no default value");
});

Suite(
Expand Down

0 comments on commit cf9b87c

Please sign in to comment.