Compare commits

...

2 Commits

Author SHA1 Message Date
Jahnertz b06bc33b21 added constants for build/src paths 2023-05-25 20:40:32 +10:00
Jahnertz 1796398d6c added processing of picture macro 2023-05-25 20:30:42 +10:00
3 changed files with 41 additions and 17 deletions

View File

@ -1,34 +1,45 @@
const fs = require('fs');
// const path = require('path');
const readline = require('readline')
const readline = require('readline');
//const src_dir = 'src';
const build_dir = 'build';
const files = ["src/index.html",
"src/projects/2016-XXXX.html",
"src/projects/2023-Pepperstone.html"]; // this list should be generated.
"src/about.html",
"src/projects/2016-XXXX.html",
"src/projects/2023-Pepperstone.html"]; // this list should be generated.
files.forEach( file => {
var file_buffer = "";
const rl = readline.createInterface({
input: fs.createReadStream(file),
output: process.stdout,
terminal: false
input: fs.createReadStream(file),
output: process.stdout,
terminal: false
});
const re = new RegExp('{% include \'*(.*)\' %}');
const re_include = new RegExp('{% include \'*(.*)\' %}');
const re_picture = new RegExp('{% picture \'*(.*)\' %}');
rl.on('line', line => {
const match = line.match(re);
if (match) {
file_buffer += fs.readFileSync(match[1], 'utf8');
} else {
file_buffer += line + "\n";
}
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('/');
ensureDirectoryExists(build_dir + '/' + picture_src);
fs.cp(match_picture[1], build_dir + '/' + picture_src, { recursive: false }, (err) => {
if (err) throw err;
});
line = line.replace(re_picture, "<img src=\'/" + picture_src + "\' \>");
}
file_buffer += line;
});
rl.on('close', () => {
ensureDirectoryExists('build/' + file.split('/').slice(1).join('/')); // all this quatch is to remove the /src/.
fs.writeFileSync('build/' + file.split('/').slice(1).join('/'), file_buffer, 'utf8');
ensureDirectoryExists(build_dir + '/' + file.split('/').slice(1).join('/')); // all this quatch is to remove the /src/.
fs.writeFileSync(build_dir + '/' + file.split('/').slice(1).join('/'), file_buffer, 'utf8');
});
});
@ -40,7 +51,7 @@ fs.cp('./src/styles','./build/styles', { recursive: true }, (err) => {
function ensureDirectoryExists(filePath) {
var dirname = filePath.split('/').slice(0,-1).join('/');
if (fs.existsSync(dirname)) {
return true;
return true;
}
ensureDirectoryExists(dirname);
fs.mkdirSync(dirname);

13
src/about.html 100644
View File

@ -0,0 +1,13 @@
{% include 'src/components/head.html' %}
{% include 'src/components/header.html' %}
<main>
<div>
{% picture 'src/images/JHN_Head_200131_v03.png' %}
</div>
<div>
<h2>Im Jordan Hanrahan — a&nbspMelbourne based art director and multidisciplinary designer.</h2>
<p>My specialties lie between the fields of communication, digital and motion design, all of which I am deeply passionate about.</p>
<p>I graduated from Swinburne University of Technology, BA. Design, Multimedia Design in 2014, and have since worked in agencies and as a freelancer all across the Asia Pacific region.</p>
</div>
</main>
{% include 'src/components/footer.html' %}

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB