diff --git a/build.js b/build.js index f5fcb8a..e4b4d20 100644 --- a/build.js +++ b/build.js @@ -1,7 +1,55 @@ const fs = require('fs'); +// const path = require('path'); +const readline = require('readline') -//todo: read through files and fill in components before copying -fs.cp('./src/','./build', { recursive: true }, (err) => { - if (err) throw err; - console.log('Build was successful!'); +const files = ["src/index.html", + "src/projects/2016-XXXX.html"]; + +files.forEach( file => { +// console.log(file + "..."); +// console.log(file.split('/').slice(1).join('/') + "\n"); //remove /src + + var file_buffer = ""; + + const rl = readline.createInterface({ + input: fs.createReadStream(file), + output: process.stdout, + terminal: false + }); + + const re = new RegExp('{% include \'*(.*)\' %}'); + + rl.on('line', line => { + const match = line.match(re); + if (match) { + file_buffer += fs.readFileSync(match[1], 'utf8'); + } else { + file_buffer += line + "\n"; + } + }); + + rl.on('close', () => { + //fs.mkdirSync('build/' + file.split('/').slice(1,-1).join('/')); // create dirs + ensureDirectoryExists('build/' + file.split('/').slice(1).join('/')); + fs.writeFileSync('build/' + file.split('/').slice(1).join('/'), file_buffer, 'utf8'); + }); }); + + +// fs.cp('./src/projects','./build/projects', { recursive: true }, (err) => { +// if (err) throw err; +// }); + +fs.cp('./src/styles','./build/styles', { recursive: true }, (err) => { + if (err) throw err; +}); + + +function ensureDirectoryExists(filePath) { + var dirname = filePath.split('/').slice(0,-1).join('/'); + if (fs.existsSync(dirname)) { + return true; + } + ensureDirectoryExists(dirname); + fs.mkdirSync(dirname); +} diff --git a/src/components/footer.html b/src/components/footer.html index 84d6054..240c9e2 100644 --- a/src/components/footer.html +++ b/src/components/footer.html @@ -1,4 +1,5 @@ - + + diff --git a/src/components/head.html b/src/components/head.html index 632e855..2f89707 100644 --- a/src/components/head.html +++ b/src/components/head.html @@ -1,8 +1,10 @@ - - - - Jordan Hanrahan - Portfolio + + + + + Jordan Hanrahan - Portfolio + diff --git a/src/index.html b/src/index.html index a7a1245..acc3f3d 100644 --- a/src/index.html +++ b/src/index.html @@ -1,28 +1,5 @@ - - - - - - - - Jordan Hanrahan - Portfolio - - -
-
- - - - -
-
+{% include 'src/components/head.html' %} +{% include 'src/components/header.html' %}
@@ -32,7 +9,4 @@
- - +{% include 'src/components/footer.html' %} diff --git a/src/projects/2016-XXXX.html b/src/projects/2016-XXXX.html index 141195f..60e7c17 100644 --- a/src/projects/2016-XXXX.html +++ b/src/projects/2016-XXXX.html @@ -1,44 +1,11 @@ - - - - - - - - Jordan Hanrahan - Portfolio - - -
-
- - - - -
-
+{% include 'src/components/head.html' %} +{% include 'src/components/header.html' %}

XX XX

Until it's recent closure, **XX XX** was one of South-East Asia's premiere venues for dance music, bringing local DJs and producers to the fore, while hosting international acts such as **Kevin Saunderson** (KMS, Detroit), **FJAAK** (50Weapons, Berlin), **Answer Code Request** (Berghain/Ostgut Ton, Berlin), Jamie XX, **Chris Cruse** (Spotlight, LA), **ND_Baumecker** (Ostgut Ton, Berlin), **Sofie** (Stones Throw/Boiler Room, LA), **Milton Bradley** (Do Not Resist The Beat/Alien Rain, Berlin) and many more.

@@ -129,9 +96,5 @@ -
- - - + +{% include 'src/components/footer.html' %}