|
@@ -17,6 +17,20 @@ projects.forEach(project => {
|
|
|
} catch(err){}
|
|
|
});
|
|
|
|
|
|
+var copyFile = function(original_path, destination_path){
|
|
|
+ try {
|
|
|
+ fs.copyFileSync(original_path, destination_path);
|
|
|
+ return true;
|
|
|
+ } catch (err){
|
|
|
+ if(err.code == 'ENOENT'){
|
|
|
+ console.log(`> ERROR: File not found! (\'${original_path}\')`)
|
|
|
+ } else {
|
|
|
+ console.log(err);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
var createProject = function(project){
|
|
|
// Don't copy private projects
|
|
|
if(project.visibility == "private") return;
|
|
@@ -24,15 +38,14 @@ var createProject = function(project){
|
|
|
var cover_path = `${source}/${project.permalink}/${project.cover_image}`
|
|
|
var cover_ext = project.cover_image.split(".")[1];
|
|
|
var thumbnail_destination = `source/images/thumbnails/projects/${project.permalink}.${cover_ext}`
|
|
|
- try {
|
|
|
- fs.copyFileSync(cover_path, thumbnail_destination);
|
|
|
- } catch (err){
|
|
|
- if(err.code == 'ENOENT'){
|
|
|
- console.log(`> ERROR: File not found! (\'${cover_path}\')`)
|
|
|
- } else {
|
|
|
- console.log(err);
|
|
|
- }
|
|
|
- return;
|
|
|
+ if(!copyFile(cover_path, thumbnail_destination)) return;
|
|
|
+ // Copy Hero
|
|
|
+ var hero_path, hero_ext, hero_destination;
|
|
|
+ if(project.hero_image != undefined){
|
|
|
+ hero_path = `${source}/${project.permalink}/${project.hero_image}`
|
|
|
+ hero_ext = project.hero_image.split(".")[1];
|
|
|
+ hero_destination = `source/images/hero/projects/${project.permalink}.${hero_ext}`
|
|
|
+ copyFile(hero_path, hero_destination);
|
|
|
}
|
|
|
// Create markdown file
|
|
|
var file = "";
|
|
@@ -41,6 +54,9 @@ var createProject = function(project){
|
|
|
file += `date: ${project.start_date}\n`;
|
|
|
file += `layout: project\n`
|
|
|
file += `cover: /images/thumbnails/projects/${project.permalink}.${cover_ext}\n`;
|
|
|
+ if(project.hero_image != undefined){
|
|
|
+ file += `hero: /images/hero/projects/${project.permalink}.${hero_ext}\n`;
|
|
|
+ }
|
|
|
try {
|
|
|
var data = JSON.parse(JSON.stringify(project));
|
|
|
delete data.title;
|