hexo-insert-markdown
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -39,3 +39,3 @@ { | ||
}, | ||
"version": "1.3.0" | ||
"version": "1.3.1" | ||
} |
@@ -10,3 +10,3 @@ const tocHelper = require('hexo/lib/plugins/helper/toc'); | ||
const [filePath, separator, tocOptions] = parseArgs(args); | ||
const html = await renderHtml(filePath, separator); | ||
const html = await renderHtml(hexo, filePath, separator); | ||
const parsedTocOptions = parseTocOptions(tocOptions); | ||
@@ -13,0 +13,0 @@ if (parsedTocOptions) { |
@@ -5,12 +5,12 @@ const pkg = require('../package.json'); | ||
function renderSeparator(separator) { | ||
function renderSeparator(hexo, separator) { | ||
return separator ? hexo.render.renderSync({text: separator, engine: 'md'}) : ''; | ||
} | ||
async function renderFile(file, separator) { | ||
async function renderFile(hexo, file, separator) { | ||
const {content} = await hexo.post.render(file); | ||
return `${content}${renderSeparator(separator)}`; | ||
return `${content}${renderSeparator(hexo, separator)}`; | ||
} | ||
async function renderHtml(filePath, separator) { | ||
async function renderHtml(hexo, filePath, separator) { | ||
const file = path.join(hexo.source_dir, filePath); | ||
@@ -29,7 +29,7 @@ | ||
.filter(filePath => path.extname(filePath) === '.md') | ||
.map(filePath => renderFile(filePath)); | ||
.map(filePath => renderFile(hexo, filePath)); | ||
const contents = await Promise.all(promises); | ||
return contents.join(renderSeparator(separator)); | ||
return contents.join(renderSeparator(hexo, separator)); | ||
} else { | ||
return renderFile(file, separator); | ||
return renderFile(hexo, file, separator); | ||
} | ||
@@ -36,0 +36,0 @@ } |
6684