]> git.r.bdr.sh - rbdr/blog/commitdiff
Allow regeneration of assets
authorRuben Beltran del Rio <redacted>
Sat, 20 Mar 2021 22:41:09 +0000 (23:41 +0100)
committerRuben Beltran del Rio <redacted>
Sat, 20 Mar 2021 22:41:09 +0000 (23:41 +0100)
bin/blog.js
lib/blog.js

index 18443aa9b84f3dc363a4f5a3b1956fcd713fdd45..7864f9ba96b6be61e63d8d423f04bcc9260de791 100755 (executable)
@@ -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)');
   }
 };
 
index 50ebbf20e31804a254f96c24c348d73b38621432..27a440e651bbb485c4091a4e8de5ef5100e930f7 100644 (file)
@@ -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');