hexo.extend.helper.register('getProjectDataHTML', function(pages){
    var projects = [];
    var project_data = []
    var s = ""
    pages.forEach(page => {
        if(page.layout == "project") projects.push(page);
    });
    projects.forEach(project => {
        var tags = [];
        var contacts = []
        project.tags.forEach(tag => {
            tags.push(tag.name);
        })
        project.contacts.forEach(contact => {
            contacts.push({ name: contact.name, url: contact.url });
        })
        project_data.push({
            title: project.title,
            folder: project.folder,
            permalink: project.permalink,
            description: project.description,
            date: project.date,
            cover_image: project.cover_image,
            hero_image: project.hero_image,
            thumbnail_image: project.thumbnail_image,
            website: project.website,
            featured: project.featured,
            tags: tags,
            start_date: project.start_date,
            end_date: project.end_date,
            contact_types: project.contact_types,
            contacts : contacts,
            text: project.text
        })
    })
    for (let i = 0; i < project_data.length; i++) {
        s += JSON.stringify(project_data[i]);
        if(i < project_data.length -1) s += ', ';
    }
    return `<script>var projectsList = [${s}]</script>`
});