Browse Source

folder creation working, console showing chopped up variables.

master
Sean Clarke 3 months ago
parent
commit
e6b82d9cc7
7 changed files with 54 additions and 2 deletions
  1. +3
    -1
      README.md
  2. +0
    -0
      config.js
  3. +22
    -1
      index.js
  4. +13
    -0
      package-lock.json
  5. +1
    -0
      package.json
  6. +0
    -0
      posts/01-15-2018-split-word-sample.md
  7. +15
    -0
      posts/10-15-2019-split-word-sample.md

+ 3
- 1
README.md View File

@@ -8,6 +8,8 @@ To be continued

## Posts Structure

Posts must be created in the following format - YYYY-MM-DAY-postname.md

### Posts Creation

The file structure can only be base, year, or month.
@@ -32,6 +34,6 @@ Each folder will have a generated index.html which provides a listing of all the

### Tag Indexing

A 'tag' folder will be generated to have an index type listing of all the tagged posts.
A 'tag' folder will be generated to have an index type listing of all the tagged posts.

[Buy me a ☕ or ☕☕](https://www.buymeacoffee.com/seanland)

+ 0
- 0
config.js View File


+ 22
- 1
index.js View File

@@ -1,4 +1,5 @@
var fs = require('fs');
var mkdirp = require('mkdirp')

var showdown = require('showdown');
var convert = new showdown.Converter();
@@ -11,11 +12,31 @@ var postsDirectory = __dirname + '/posts';
if(!fs.existsSync(site))
fs.mkdirSync(site);

// reading all posts from the post directory
fs.readdir(postsDirectory, function(err, posts){
if(err) throw err;

posts.forEach(function(post){
// split post file name to create the required site structure
var postInfo = post.split('-');
// parted out information
var month = postInfo.shift();
var day = postInfo.shift();
var year = postInfo.shift();
var name = postInfo.join('-');

// Making the required directory for the post
mkdirp(site + '/' + year + '/' + month, function(err){
if(err) throw err;
});


console.log(year);
console.log(month);
console.log(day);
console.log(name);
console.log(post);
})
});
});
//
// fs.readFile(__dirname + '/posts/sample.md', 'utf-8', function(err, data){


+ 13
- 0
package-lock.json View File

@@ -141,6 +141,19 @@
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"requires": {
"minimist": "0.0.8"
}
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",


+ 1
- 0
package.json View File

@@ -7,6 +7,7 @@
"remove-site": "node remove-site.js"
},
"dependencies": {
"mkdirp": "^0.5.1",
"rimraf": "^3.0.0",
"showdown": "^1.9.1"
}


posts/10-15-2019-sample.md → posts/01-15-2018-split-word-sample.md View File


+ 15
- 0
posts/10-15-2019-split-word-sample.md View File

@@ -0,0 +1,15 @@






# Post Title!

This is some text. I am happy to write this text. This will show how it works.

## Sub-category none

This is the first sub-category. I will probably throw an image in this section. This will show how a post image will work.

This is just a link to [Buy me a ☕ or ☕☕](https://www.buymeacoffee.com/seanland)

Loading…
Cancel
Save