${raw(renderedMarkdown)}
${raw(pageScript)}
`;
};
// H E L P E R
function partialFinder(markdownBody) {
const regexToFindPartials = /<\w+\/>/g;
const partials = markdownBody.match(regexToFindPartials);
if (!partials) return markdownBody;
for (const partial of partials) {
const filename = decamelize(partial, "-").replace("<", "").replace("/>", "");
const fileExistsTest = exists(`./views/partials/${filename}.js`); // `local` results in error if used here and file !exist
if (fileExistsTest) {
const partialFunction = local(`/views/partials/${filename}.js`);
if (filename === "ecosystem") {
const Ecosystem = new partialFunction;
markdownBody = markdownBody.replace(partial, Ecosystem.render());
}
else markdownBody = markdownBody.replace(partial, partialFunction);
}
}
return dedent(markdownBody); // partials get rendered as code snippets w/o `dedent`
}