fix markdown rendering

This commit is contained in:
Jeremy Kauffman 2018-10-16 10:12:15 -04:00
parent 7e90e092d6
commit fc2e34c2a5

View file

@ -62,22 +62,22 @@ function partialFinder(markdownBody) {
const regexToFindPartials = /<\w+ ?\/>/g; const regexToFindPartials = /<\w+ ?\/>/g;
const partials = markdownBody.match(regexToFindPartials); const partials = markdownBody.match(regexToFindPartials);
if (!partials) return markdownBody; if (partials) {
for (const partial of partials) {
const filename = decamelize(partial, "-").replace("<", "")
.replace("/>", "")
.trim();
const fileExistsTest = exists(`./app/components/${filename}.js`); // `local` results in error if used here and file !exist
for (const partial of partials) { if (!fileExistsTest)
const filename = decamelize(partial, "-").replace("<", "") markdownBody = markdownBody.replace(partial, "");
.replace("/>", "")
.trim();
const fileExistsTest = exists(`./app/components/${filename}.js`); // `local` results in error if used here and file !exist
if (!fileExistsTest) else {
markdownBody = markdownBody.replace(partial, ""); const partialFunction = require(path.join(__dirname, "..", `./components/${filename}.js`));
else { if (filename === "glossary-toc") markdownBody = markdownBody.replace(partial, partialFunction);
const partialFunction = require(path.join(__dirname, "..", `./components/${filename}.js`)); else markdownBody = markdownBody.replace(partial, `</div>${partialFunction.default()}<div class="page__markup">`);
}
if (filename === "glossary-toc") markdownBody = markdownBody.replace(partial, partialFunction);
else markdownBody = markdownBody.replace(partial, `</div>${partialFunction.default()}<div class="page__markup">`);
} }
} }