Sign in

Get posts by main tag

#2575
Avatar photo[anonymous]
let themeHelpers = {
    getPostsByMainTag: function(mainTag, content) {

        const postsData = JSON.parse(JSON.stringify(content.data.website.contentStructure.posts));

        let filteredPosts = [];

        postsData.forEach(function(post) {

            post.mainTag.slug == mainTag && filteredPosts.push(content.fn(post));
        });

        return filteredPosts.join();
    }
};
module.exports = themeHelpers;