From: Ruben Beltran del Rio Date: Sat, 20 Mar 2021 22:41:09 +0000 (+0100) Subject: Allow regeneration of assets X-Git-Tag: 5.0.0~21 X-Git-Url: https://git.r.bdr.sh/rbdr/blog/commitdiff_plain/e54f8139d084e0c8b2ad67e084cbeda3a2e35c90?ds=sidebyside;hp=9e355758760cfa0c3d34759d22875c9d82ddd971 Allow regeneration of assets --- diff --git a/bin/blog.js b/bin/blog.js index 18443aa..7864f9b 100755 --- a/bin/blog.js +++ b/bin/blog.js @@ -7,7 +7,7 @@ const Minimist = require('minimist'); const internals = { blog: new Blog(Config), - expectedKeys: ['add', 'update', 'publish'], + expectedKeys: ['add', 'generate', 'update', 'publish'], // Application entry point. Reads arguments and calls the // corresponding method from the blog lib @@ -32,6 +32,11 @@ const internals = { return; } + if (argument === 'generate') { + await internals.blog.generate(); + return; + } + if (argument === 'publish') { await internals.blog.publish(value); return; @@ -76,8 +81,9 @@ const internals = { console.error('\nUsage:\n'); console.error('blog --add path/to/blog_post\t\t(creates new blog post)'); - console.error('blog --update path/to/blog_post\t(updates latest blog post)'); - console.error('blog --publish \t\t\t(publishes the blog)'); + console.error('blog --update path/to/blog_post\t\t(updates latest blog post)'); + console.error('blog --generate \t\t\t(generates the blog assets)'); + console.error('blog --publish \t\t\t\t(publishes the blog)'); } }; diff --git a/lib/blog.js b/lib/blog.js index 50ebbf2..27a440e 100644 --- a/lib/blog.js +++ b/lib/blog.js @@ -81,7 +81,7 @@ module.exports = class Blog { await this._copyPost(postLocation); await this._writeMetadata(metadata); - await this._generate(); + await this.generate(); } /** @@ -100,7 +100,7 @@ module.exports = class Blog { // Parses markdown for each page, copies assets and generates index. - async _generate() { + async generate() { internals.debuglog('Generating output');