From 4addbac3fbe52fc3a006d05c80ae234eecf8e0c4 Mon Sep 17 00:00:00 2001 From: Dan Jones Date: Wed, 21 Dec 2022 15:57:06 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20Build=20system=20works?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + Makefile | 5 +++++ compile.js | 20 ++++++++++++++++++++ config.toml | 1 + index.html | 8 ++++++++ package.json | 4 ++-- 6 files changed, 37 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 15813be..81dd746 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ package-lock.json node_modules/ +*.~undo-tree~ diff --git a/Makefile b/Makefile index e69de29..cc8b31e 100644 --- a/Makefile +++ b/Makefile @@ -0,0 +1,5 @@ +build/index.html: build/style.css index.html config.toml compile.js + node compile.js + +build/style.css: scss/style.scss + npx sass $< $@ diff --git a/compile.js b/compile.js index e69de29..2f1d073 100644 --- a/compile.js +++ b/compile.js @@ -0,0 +1,20 @@ +const { parse } = require('@ltd/j-toml'); +const { render } = require('mustache'); +const { readFile, writeFile } = require('node:fs/promises'); +const { resolve } = require('node:path'); + +async function compile() { + const confPath = resolve('./config.toml'); + const confToml = await readFile(confPath, { encoding: 'utf8' }); + const config = parse(confToml); + + const tempPath = resolve('./index.html'); + const template = await readFile(tempPath, { encoding: 'utf8' }); + + const out = render(template, config); + const outPath = resolve('./build/index.html'); + + await writeFile(outPath, out); +} + +compile(); diff --git a/config.toml b/config.toml index e69de29..6a252af 100644 --- a/config.toml +++ b/config.toml @@ -0,0 +1 @@ +title = "Dan Jones's Links" diff --git a/index.html b/index.html index e69de29..fb567e3 100644 --- a/index.html +++ b/index.html @@ -0,0 +1,8 @@ + + + + + {{title}} + + + diff --git a/package.json b/package.json index 8c51ca1..3b34f0f 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ "author": "Dan Jones", "license": "AGPL-3.0-or-later", "dependencies": { + "@ltd/j-toml": "^1.36.0", "mustache": "^4.2.0", - "sass": "^1.57.1", - "toml-nodejs": "^0.2.0" + "sass": "^1.57.1" } }