Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

allow contentDir to be defined in config.json #34

Closed
wants to merge 6 commits into from

3 participants

@morganrallen

Sorry for double commit, this should only be for aa4a274
When defining contentDir in config.json blacksmith post will output content to that location.

@jfhbrook

Hi @morganrallen,

This looks handy, but I'm not quite sure how it works. Would you mind producing some examples showing me how this is used?

@morganrallen

The basic idea it to set contentDir to "./pages" and then blacksmith post will create the content directories there to be picked up by blacksmith generate. Generate should probably honor it also that way content directory could be somewhere separate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 1 deletion.
  1. +15 −1 lib/commands/post.js
View
16 lib/commands/post.js
@@ -1,11 +1,21 @@
var smith = require("../blacksmith"),
fs2 = require('../fs2'),
winston = require('winston'),
+ path = require('path'),
prompt = require("prompt");
module.exports = function() {
winston.info("Executing command "+"post".yellow);
+ var defaultAuthor = smith.config.get("defaultAuthor"),
+ defaultAuthorName;
+ if(defaultAuthor && path.existsSync('./authors/'+defaultAuthor+'.json')) {
+ var author = require("../loaders/authors").load(true)[defaultAuthor];
+ if(author) {
+ defaultAuthorName = author.get("name");
+ }
+ }
+
prompt.start();
prompt.get([
{
@@ -14,7 +24,7 @@ module.exports = function() {
},
{
name: "author",
- message: "Specify the author"
+ message: "Specify the author" + (defaultAuthorName ? " (empty to use '"+defaultAuthorName+"')" : "")
}
], function (err, res) {
if (err) {
@@ -22,6 +32,10 @@ module.exports = function() {
cb(1);
}
+ if(res.author === "") {
+ res.author = defaultAuthorName;
+ }
+
var folder = res.title.toLowerCase().replace(/\W+/g, '-');
//TODO: Check authors
Something went wrong with that request. Please try again.