diff --git a/bin/generator.js b/bin/generator.js index c5d9585..61240ec 100644 --- a/bin/generator.js +++ b/bin/generator.js @@ -67,8 +67,17 @@ async function generator(configFilename, distPath, opt){ // write content to file await _fs.writeFile(_path.join(distPath, templateVars.scheme), content, 'utf8'); - console.log(` |- Page <${templateVars.scheme}>`); + + const jsonContent = { + "status": Number(templateVars.code), + "title": templateVars.title, + "detail": templateVars.message + } + + await _fs.writeFile(_path.join(distPath, templateVars.baseScheme) + '.json', JSON.stringify(jsonContent, null, 4), 'utf8'); + console.log(` |- Page <${templateVars.baseScheme}.json>`); + })); } @@ -131,4 +140,4 @@ _cli.parse(process.argv); // default action (no command provided) if (!process.argv.slice(2).length) { _cli.outputHelp(); -} \ No newline at end of file +} diff --git a/config-dist.json b/config-dist.json index dab23ff..33c4888 100644 --- a/config-dist.json +++ b/config-dist.json @@ -1,10 +1,11 @@ { // Output Filename Scheme - eg. HTTP500.html "scheme": "HTTP%code%.html", + "baseScheme": "HTTP%code%", // Page title (HTML not allowed) "pagetitle": "We've got some trouble | %code% - %title%", // Footer content (HTML Allowed) "footer": null -} \ No newline at end of file +} diff --git a/config.json b/config.json index b709d9f..3b912f8 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,7 @@ { // Output Filename Scheme - eg. HTTP500.html "scheme": "HTTP%code%.html", + "baseScheme": "HTTP%code%", // Page title (HTML not allowed) "pagetitle": "We've got some trouble | %code% - %title%", @@ -10,4 +11,4 @@ // additional vars "myvar" : "Hello World" -} \ No newline at end of file +}