Browse Source

Post model getPost created, upated Readme.md

master
Sean Clarke 9 months ago
parent
commit
98f56a9761
3 changed files with 13 additions and 2 deletions
  1. +5
    -0
      README.md
  2. +1
    -1
      index.js
  3. +7
    -1
      model/Post.js

+ 5
- 0
README.md View File

@@ -2,6 +2,11 @@

Build a blog using markdown files

## Rules!
md file structure has to follow these conditions:
* post specifics have to be tagged at the top of the page starting with '<--' and ending with '-->'. (Use the template)
* each post must then have a # heading.

## File Structure

To be continued


+ 1
- 1
index.js View File

@@ -33,4 +33,4 @@ var posts = new Listing();

posts = allPosts.forYearAndMonth(2018, 01);

console.log(posts);
console.log(posts.posts[0].getPost());

+ 7
- 1
model/Post.js View File

@@ -23,7 +23,7 @@ var Post = function(data){

Post.prototype.getDetails = function(){
// Patten to match the 'comment' section
var pattern = new RegExp(/^<--(.|\n)*-->/);
var pattern = new RegExp(/^<--(.|\n)*-->/); // set g later?
var options = fs.readFileSync(this.md, 'utf8').match(pattern)[0];
var details = [];

@@ -39,4 +39,10 @@ Post.prototype.getDetails = function(){
return details;
};

Post.prototype.getPost = function(){
var pattern = new RegExp(/#(.|\n)*/);
var options = fs.readFileSync(this.md, 'utf8').match(pattern)[0];
return options;
}

module.exports = Post;

Loading…
Cancel
Save