function loadGhostPosts(arr){

    var ghostAPI = new GhostContentAPI({
        url: arr.url,
        key: arr.key,
        version: arr.version
    });

    return ghostAPI.posts
        .browse({
            include: 'authors',
            fields: ['title', 'url', 'published_at', 'feature_image'],
            limit: arr.limit,
            page: arr.page
        })
        .then(function(posts){

            for(const v of posts){
                var authors = '';
                for(const a of v.authors){
                    authors += a.name + ', ';
                }
                authors = authors.slice(0,-2);

                var date = moment(v.published_at, 'YYYY-MM-DDTHH:mm:ssZ').format('D MMMM YYYY');

                allPosts.push({
                    'title': v.title,
                    'url': v.url,
                    'feature_image': v.feature_image,
                    'date': date,
                    'defaultDate': v.published_at,
                    'authors': authors,
                    'blog': arr.blog
                });
            }

        })
        .catch(function(err){
            console.error(err);
        });
}
// Function to load posts from Ghost blog
Function to load posts from Ghost blog
Function to load posts from Ghost blog
function loadGhostPosts(arr){
    var ghostAPI = new GhostContentAPI({
        url: arr.url,
        key: arr.key,
        version: arr.version
    });
    return ghostAPI.posts
        .browse({
            include: 'authors',
            fields: ['title', 'url', 'published_at', 'feature_image'],
            limit: arr.limit,
            page: arr.page
        })
        .then(function(posts){
            for(const v of posts){
                var authors = '';
                for(const a of v.authors){
                    authors += a.name + ', ';
                }
                authors = authors.slice(0,-2);
                var date = moment(v.published_at, 'YYYY-MM-DDTHH:mm:ssZ').format('D MMMM YYYY');
                allPosts.push({
                    'title': v.title,
                    'url': v.url,
                    'feature_image': v.feature_image,
                    'date': date,
                    'defaultDate': v.published_at,
                    'authors': authors,
                    'blog': arr.blog
                });
            }
        })
        .catch(function(err){
            console.error(err);
        });
}
function loadGhostPosts ( arr ) { var ghostAPI = new GhostContentAPI ( { url : arr . url , key : arr . key , version : arr . version } ) ; return ghostAPI . posts . browse ( { include : 'authors' , fields : [ 'title' , 'url' , 'published_at' , 'feature_image' ] , limit : arr . limit , page : arr . page } ) . then ( function ( posts ) { for ( const v of posts ) { var authors = '' ; for ( const a of v . authors ) { authors += a . name + ', ' ; } authors = authors . slice ( 0 , - 2 ) ; var date = moment ( v . published_at , 'YYYY-MM-DDTHH:mm:ssZ' ) . format ( 'D MMMM YYYY' ) ; allPosts . push ( { 'title' : v . title , 'url' : v . url , 'feature_image' : v . feature_image , 'date' : date , 'defaultDate' : v . published_at , 'authors' : authors , 'blog' : arr . blog } ) ; } } ) . catch ( function ( err ) { console . error ( err ) ; } ) ; }
Function to load posts from Ghost blog
Function to load posts from Ghost blog