readPosts () {
        let post;
        let postName; 
        let postDate; 
        let postPath;
        let postContent;
        let postYAML; 
        let postMarkdown;
        let data;
        let folder = this.folder;
        let re = /(\.md|\.markdown)$/i;

        if ( ! fs.existsSync(folder) ) {
            console.log( logWarn(`Folder > ${folder} < does not exists.`) );
            console.log( logWarn('Make sure to enter the right path to jekyll folder containing the markdown files.') );

            return false;
        }

        fs.readdir(folder, (error, files) => {
            if ( error || files.length < 1 ) {
                console.log( logWarn(`Cant read files at ${folder}`) );
                return;
            }

            for ( let i = 0; i < files.length; i++ ) {
                let postObj = {};
                post = files[i];
                postPath = path.join(folder, post);

                if ( ! re.exec(post) ) {
                    console.log( logWarn(`Something went wrong reading post ${post}`) );
                    continue;
                }

                postName = this.extractPostName(post);
                postDate = this.extractPostDate(post);

                data = fs.readFileSync(postPath);

                if ( ! data ) {
                    console.log( logWarn(`Something went wrong reading post ${post}`) );
                    return;
                }

                postContent = data.toString();
                postYAML = this.extractPostYAML(postContent);
                postMarkdown = this.extractPostMarkdown(postContent);

                postObj['id'] = i;
                postObj['uuid'] = uuid.v4();
                postObj['title'] = postYAML.title;
                postObj['slug'] = postName;
                postObj['markdown'] = postMarkdown;
                postObj['html'] = markdown.toHTML(postMarkdown);
                postObj['image'] = null;
                postObj['featured'] = 0;
                postObj['page'] = 0;
                postObj['status'] = 'published';
                postObj['language'] = 'en_US';
                postObj['meta_title'] = postYAML.title;
                postObj['meta_description'] = null;
                postObj['author_id'] = 1;
                postObj['created_at'] = Date.parse(postDate);
                postObj['created_by'] = 1;
                postObj['updated_at'] = Date.parse(postDate);
                postObj['updated_by'] = 1;
                postObj['published_at'] = Date.parse(postDate);
                postObj['published_by'] = 1;

                this.populatePosts(postObj);

                if ( (this.ghostObj.data.posts.length + 1) === files.length ) {
                    this.writeToFile();
                }

            }
        });
    }
/**
     * Extract content from markdown post
     * create post json object
     * @method readPosts
     */
Extract content from markdown post
create post json object
@method readPosts
Extract content from markdown post create post json object @method readPosts
readPosts () {
        let post;
        let postName; 
        let postDate; 
        let postPath;
        let postContent;
        let postYAML; 
        let postMarkdown;
        let data;
        let folder = this.folder;
        let re = /(\.md|\.markdown)$/i;
        if ( ! fs.existsSync(folder) ) {
            console.log( logWarn(`Folder > ${folder} < does not exists.`) );
            console.log( logWarn('Make sure to enter the right path to jekyll folder containing the markdown files.') );
            return false;
        }
        fs.readdir(folder, (error, files) => {
            if ( error || files.length < 1 ) {
                console.log( logWarn(`Cant read files at ${folder}`) );
                return;
            }
            for ( let i = 0; i < files.length; i++ ) {
                let postObj = {};
                post = files[i];
                postPath = path.join(folder, post);
                if ( ! re.exec(post) ) {
                    console.log( logWarn(`Something went wrong reading post ${post}`) );
                    continue;
                }
                postName = this.extractPostName(post);
                postDate = this.extractPostDate(post);
                data = fs.readFileSync(postPath);
                if ( ! data ) {
                    console.log( logWarn(`Something went wrong reading post ${post}`) );
                    return;
                }
                postContent = data.toString();
                postYAML = this.extractPostYAML(postContent);
                postMarkdown = this.extractPostMarkdown(postContent);
                postObj['id'] = i;
                postObj['uuid'] = uuid.v4();
                postObj['title'] = postYAML.title;
                postObj['slug'] = postName;
                postObj['markdown'] = postMarkdown;
                postObj['html'] = markdown.toHTML(postMarkdown);
                postObj['image'] = null;
                postObj['featured'] = 0;
                postObj['page'] = 0;
                postObj['status'] = 'published';
                postObj['language'] = 'en_US';
                postObj['meta_title'] = postYAML.title;
                postObj['meta_description'] = null;
                postObj['author_id'] = 1;
                postObj['created_at'] = Date.parse(postDate);
                postObj['created_by'] = 1;
                postObj['updated_at'] = Date.parse(postDate);
                postObj['updated_by'] = 1;
                postObj['published_at'] = Date.parse(postDate);
                postObj['published_by'] = 1;
                this.populatePosts(postObj);
                if ( (this.ghostObj.data.posts.length + 1) === files.length ) {
                    this.writeToFile();
                }
            }
        });
    }
readPosts ( ) { let post ; let postName ; let postDate ; let postPath ; let postContent ; let postYAML ; let postMarkdown ; let data ; let folder = this . folder ; let re = / (\.md|\.markdown)$ / i ; if ( ! fs . existsSync ( folder ) ) { console . log ( logWarn ( ` ${ folder } ` ) ) ; console . log ( logWarn ( 'Make sure to enter the right path to jekyll folder containing the markdown files.' ) ) ; return false ; } fs . readdir ( folder , ( error , files ) => { if ( error || files . length < 1 ) { console . log ( logWarn ( ` ${ folder } ` ) ) ; return ; } for ( let i = 0 ; i < files . length ; i ++ ) { let postObj = { } ; post = files [ i ] ; postPath = path . join ( folder , post ) ; if ( ! re . exec ( post ) ) { console . log ( logWarn ( ` ${ post } ` ) ) ; continue ; } postName = this . extractPostName ( post ) ; postDate = this . extractPostDate ( post ) ; data = fs . readFileSync ( postPath ) ; if ( ! data ) { console . log ( logWarn ( ` ${ post } ` ) ) ; return ; } postContent = data . toString ( ) ; postYAML = this . extractPostYAML ( postContent ) ; postMarkdown = this . extractPostMarkdown ( postContent ) ; postObj [ 'id' ] = i ; postObj [ 'uuid' ] = uuid . v4 ( ) ; postObj [ 'title' ] = postYAML . title ; postObj [ 'slug' ] = postName ; postObj [ 'markdown' ] = postMarkdown ; postObj [ 'html' ] = markdown . toHTML ( postMarkdown ) ; postObj [ 'image' ] = null ; postObj [ 'featured' ] = 0 ; postObj [ 'page' ] = 0 ; postObj [ 'status' ] = 'published' ; postObj [ 'language' ] = 'en_US' ; postObj [ 'meta_title' ] = postYAML . title ; postObj [ 'meta_description' ] = null ; postObj [ 'author_id' ] = 1 ; postObj [ 'created_at' ] = Date . parse ( postDate ) ; postObj [ 'created_by' ] = 1 ; postObj [ 'updated_at' ] = Date . parse ( postDate ) ; postObj [ 'updated_by' ] = 1 ; postObj [ 'published_at' ] = Date . parse ( postDate ) ; postObj [ 'published_by' ] = 1 ; this . populatePosts ( postObj ) ; if ( ( this . ghostObj . data . posts . length + 1 ) === files . length ) { this . writeToFile ( ) ; } } } ) ; }
Extract content from markdown post
 create post json object
 @method readPosts
Extract content from markdown post create post json object @method readPosts