Commit eccb3cc4 authored by Rubén Beltran del Río's avatar Rubén Beltran del Río 🐝

Fix generator when there are < max posts

parent 5e265f9d
......@@ -112,20 +112,33 @@ module.exports = class Blog {
for (let i = 0; i < this.maxPosts; ++i) {
const sourcePath = Path.join(this.postsDirectory, `${i}`);
const assetsSource = Path.join(sourcePath, internals.kAssetsDirectoryName);
const postContentPath = await this._findBlogContent(sourcePath);
internals.debuglog(`Copying ${assetsSource} to ${assetsTarget}`);
await internals.ncp(assetsSource, assetsTarget);
try {
await internals.fs.access(this.postsDirectory);
const assetsSource = Path.join(sourcePath, internals.kAssetsDirectoryName);
const postContentPath = await this._findBlogContent(sourcePath);
internals.debuglog(`Copying ${assetsSource} to ${assetsTarget}`);
await internals.ncp(assetsSource, assetsTarget);
internals.debuglog(`Reading ${postContentPath}`);
const postContent = await internals.fs.readFile(postContentPath, { encoding: 'utf8' });
internals.debuglog(`Reading ${postContentPath}`);
const postContent = await internals.fs.readFile(postContentPath, { encoding: 'utf8' });
internals.debuglog('Parsing markdown');
posts.push({
html: Markdown.markdown.toHTML(postContent),
id: i + 1
});
internals.debuglog('Parsing markdown');
posts.push({
html: Markdown.markdown.toHTML(postContent),
id: i + 1
});
}
catch (error) {
if (error.code === internals.kFileNotFoundError) {
internals.debuglog(`Skipping ${i}`);
continue;
}
throw error;
}
}
internals.debuglog(`Reading ${indexLocation}`);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment