Skip to content

Commit

Permalink
Allow drafts
Browse files Browse the repository at this point in the history
  • Loading branch information
astronomersiva committed Sep 2, 2018
1 parent 2233f92 commit 9033a07
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/lego.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ module.exports = async function(args) {
return;
}

const site = new Site();

if (['s', 'server'].includes(task)) {
const site = new Site({ development: true });
await runTask(server, site);
watch(site, runTask);
} else {
const site = new Site();
await runTask([...build, 'revisionAssets'], site);

site.logger.success(`Build created at ${chalk.cyan(BUILD)}.`);
Expand Down
23 changes: 19 additions & 4 deletions lib/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ const loadData = require('./utils/loadData');
const { BUILD, POSTS } = require('./utils/constants');

class Site {
constructor() {
constructor(development = false) {
this._development = development;
this._posts = [];
this._data = [];
this._tags = [];
this._assets = {};

this.logger = new Signale({ interactive: true });
if (process.env.DEBUG) {
let consoleLog = console.log;
Expand Down Expand Up @@ -50,8 +52,15 @@ class Site {
html
}, meta);

this._posts.push(postData);
this._tags = this._tags.concat(postData.tags || []);
if (meta.draft) {
if (this._development) {
this._posts.push(postData);
this._tags = this._tags.concat(postData.tags || []);
}
} else {
this._posts.push(postData);
this._tags = this._tags.concat(postData.tags || []);
}
}

this.logger.success('Preparing site');
Expand Down Expand Up @@ -89,7 +98,13 @@ class Site {
}, meta);

if (event === 'add') {
this._posts.push(postData);
if (meta.draft) {
if (this._development) {
this._posts.push(postData);
}
} else {
this._posts.push(postData);
}
} else {
let changedPostIndex = this._posts
.findIndex(element => element.path === postName);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@astronomersiva/lego",
"version": "0.0.8",
"version": "0.0.9",
"description": "A custom built static site generator that will one day power [sivasubramanyam.me](https://sivasubramanyam.me) 🏋️‍",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 9033a07

Please sign in to comment.