static-markdown
Advanced tools
Comparing version 1.1.0 to 1.2.0
30
index.js
@@ -12,3 +12,3 @@ const Handlebars = require('handlebars') | ||
async function renderArticle(dir, articlePath, template, constants) { | ||
async function renderArticle(dir, articlePath, constants) { | ||
// each line | ||
@@ -22,3 +22,16 @@ let articleLines = fs.readFileSync(articlePath, { | ||
// others are the content | ||
// {"template": "template"} by default | ||
let templateToUse = articleMetadata.template || 'template' | ||
// load template | ||
let templateFile | ||
try { | ||
templateFile = await fs.readFile(path.join(dir, `source/${templateToUse}.html`), { | ||
encoding: 'utf8' | ||
}) | ||
} catch (e) { | ||
return error(`Could not find source/${templateToUse}.html`) | ||
} | ||
let template = Handlebars.compile(templateFile) | ||
// most lines are the content | ||
let articleFile = articleLines.join('\n') | ||
@@ -95,13 +108,2 @@ | ||
// load template | ||
let templateFile | ||
try { | ||
templateFile = await fs.readFile(path.join(dir, 'source/template.html'), { | ||
encoding: 'utf8' | ||
}) | ||
} catch (e) { | ||
return error('Could not find source/template.html') | ||
} | ||
let template = Handlebars.compile(templateFile) | ||
let articlePaths | ||
@@ -134,3 +136,3 @@ // find all articles | ||
for (let articleFileNumber in articlePaths) { | ||
renderArticle(dir, articlePaths[articleFileNumber], template, constants) | ||
renderArticle(dir, articlePaths[articleFileNumber], constants) | ||
} | ||
@@ -137,0 +139,0 @@ } |
{ | ||
"name": "static-markdown", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Generate static sites using markdown", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
6944
133
0