Add YML instead of JSON, simplifying README

This commit is contained in:
Moutonjr Geoff 2020-11-21 15:18:19 +01:00
parent 6d7d598290
commit 3bb7a6fb15
4 changed files with 14 additions and 14 deletions

View File

@ -11,12 +11,17 @@ Scheme is as follows:
- Can't properly handle modular breakdown (header, footer, sections);
- When you made it work once, shall you re-understand everything 6 months later to thange stubs?
Here is how it works:
#### What should I open?
- `template/index.njk` is a good start,
- then `settings.yml`,
- Then run the script and see the `public/index.html` folder. It explains it all.
#### Here is how it works:
- We store relevant data in a YAML file, say `settings.yml`.
- We Use [Nunjucks](https://mozilla.github.io/nunjucks/templating.html), the millenials way to code, to generate Jinja2-styled webpages on steroids.
- We Then compile the whole _once_, and after we got static HTML for basically every use.
- We Then compile the whole _once_, and after we got static HTML in `public/` folder for basically every use.
What repo doesn't contain:
#### What this repo doesn't contain:
- All Nunjucks killer features.
## Dependencies
@ -24,7 +29,7 @@ Install NodeJS and npm
## Build
```bash
npm run build
npm install
```
Serve your webserver to display the `public` folder as webroot.

View File

@ -10,14 +10,10 @@ try {
let fileContents = fs.readFileSync(GLOBAL_SETTINGS, 'utf8');
let settings = yaml.safeLoad(fileContents);
console.log(data);
var data = nunjucks.render(ENTRY_POINT, settings);
fs.writeFile(OUTPUT_POINT, data, 'utf-8');
} catch (e) {
console.log(e);
}
var data = nunjucks.render(ENTRY_POINT, settings);
fs.writeFile(OUTPUT_POINT, data, 'utf-8', function(err){
if (err) return console.log(err);
});

View File

@ -1,3 +0,0 @@
{
"dinner": "ready"
}

2
settings.yml Normal file
View File

@ -0,0 +1,2 @@
---
dinner: "ready"