diff --git a/build.js b/build.js index f7c7db5..6b55591 100644 --- a/build.js +++ b/build.js @@ -1,6 +1,6 @@ const fs = require('fs'); const readline = require('readline'); -//const src_dir = 'src'; +const src_dir = 'src'; const build_dir = 'build'; const files = ["src/index.html", @@ -9,36 +9,39 @@ const files = ["src/index.html", "src/projects/2023-Pepperstone.html"]; // this list should be generated. files.forEach( file => { - var file_buffer = ""; + var file_buffer = ""; - const rl = readline.createInterface({ + const rl = readline.createInterface({ input: fs.createReadStream(file), output: process.stdout, terminal: false - }); + }); - const re_include = new RegExp('{% include \'*(.*)\' %}'); - const re_picture = new RegExp('{% picture \'*(.*)\' %}'); + const re_include = new RegExp('{% include \'*(.*)\' %}'); + const re_picture = new RegExp('{% picture.*%}'); - rl.on('line', line => { + rl.on('line', line => { const match_include = line.match(re_include); const match_picture = line.match(re_picture); if (match_include) { line = line.replace(re_include, fs.readFileSync(match_include[1], 'utf8')); } if (match_picture) { - const picture_src = match_picture[1].split('/').slice(1).join('/'); + const re_src = new RegExp("src=[\'\"](.*?)[\'\"]"); + const picture_src = match_picture[0].match(re_src)[1].split('/').slice(1).join('/'); + const re_alt = new RegExp("alt=[\'\"](.*?)[\'\"]"); + const alt = match_picture[0].match(re_alt)[1]; ensureDirectoryExists(build_dir + '/' + picture_src); - fs.cp(match_picture[1], build_dir + '/' + picture_src, { recursive: false }, (err) => { + fs.cp(src_dir + '/' + picture_src, build_dir + '/' + picture_src, { recursive: false }, (err) => { if (err) throw err; }); - line = line.replace(re_picture, ""); + line = line.replace(re_picture, "\'""); } file_buffer += line; - }); - - rl.on('close', () => { - ensureDirectoryExists(build_dir + '/' + file.split('/').slice(1).join('/')); // all this quatch is to remove the /src/. + }); + + rl.on('close', () => { + ensureDirectoryExists(build_dir + '/' + file.split('/').slice(1).join('/')); fs.writeFileSync(build_dir + '/' + file.split('/').slice(1).join('/'), file_buffer, 'utf8'); }); }); diff --git a/src/about.html b/src/about.html index 4f0f825..426484f 100644 --- a/src/about.html +++ b/src/about.html @@ -2,7 +2,7 @@ {% include 'src/components/header.html' %}
- {% picture 'src/images/JHN_Head_200131_v03.png' %} + {% picture src='src/images/JHN_Head_200131_v03.png' alt='Face line-drawing' %}

I’m Jordan Hanrahan — a Melbourne based art director and multi−disciplinary designer.