var slugify = require('./slugify');
var join = require('path').join;
var moment = require('moment');

module.exports = function (title, page, draft, dateStamp) {

  var relative_path_without_extension;

  var slug = slugify(title);
  var name = name || slug;

  name = name.split('/').join('-');

  if (page) {
    relative_path_without_extension = join('Pages', name);
  } else if (draft) {
    relative_path_without_extension = join('Drafts', name);
  } else {
    relative_path_without_extension = join(moment(dateStamp).format('YYYY'), moment(dateStamp).format('MM') + '-' + moment(dateStamp).format('DD') + '-' + name);
  }     

  return relative_path_without_extension;
};
@@ -15,17 +15,17 @@
 require(
-'
+%22
 ./slugif
@@ -25,17 +25,17 @@
 /slugify
-'
+%22
 );%0Avar j
@@ -52,14 +52,14 @@
 ire(
-'
+%22
 path
-'
+%22
 ).jo
@@ -87,16 +87,16 @@
 ire(
-'
+%22
 moment
-'
+%22
 );%0A%0A
@@ -120,17 +120,16 @@
 function
- 
 (title, 
@@ -154,13 +154,18 @@
 tamp
+, slug
 ) %7B%0A
-%0A
   va
@@ -199,23 +199,31 @@
 ension;%0A
-%0A
   var 
+name;%0A%0A  
 slug = s
@@ -238,16 +238,20 @@
 itle
+ %7C%7C slug
 );%0A 
- var
  nam
@@ -293,21 +293,21 @@
 lit(
-'/'
+%22/%22
 ).join(
-'-'
+%22-%22
 );%0A%0A
@@ -367,15 +367,15 @@
 oin(
-'
+%22
 Pages
-'
+%22
 , na
@@ -448,16 +448,16 @@
 oin(
-'
+%22
 Drafts
-'
+%22
 , na
@@ -515,16 +515,23 @@
  = join(
+%0A      
 moment(d
@@ -551,16 +551,22 @@
 mat(
-'
+%22
 YYYY
-'
+%22
 ),
+%0A     
  mom
@@ -591,21 +591,37 @@
 mat(
-'MM') + '-' +
+%22MM%22) +%0A        %22-%22 +%0A       
  mom
@@ -646,37 +646,53 @@
 mat(
-'DD') + '-' + name
+%22DD%22) +%0A        %22-%22 +%0A        name%0A    
 );%0A  %7D
-     
 %0A%0A  
@@ -733,8 +733,9 @@
 sion;%0A%7D;
+%0A

Allow optional slug in function which determines an imported entry's path