Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jbottigliero committed May 22, 2024
0 parents commit 8f16dd2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
out
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# `generator-hello-world`

This is a basic example of a `generator` in the static Application Design Approach. A `generator` (static site generator) processes a `static.json` file and produces a static web page or dynamic web application.

By referencing this `generator` in a `static.json` file and providing a `data.message` value, the `generator` will produce a static web page with the provided `data.message`.

A template repository that references this generator can be found at: https://github.com/from-static/template-hello-world.

This template repository can be used to create custom distributions of the generator on GitHub Pages by only modifying the `data.message` value in the `static.json` file.
18 changes: 18 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const fs = require('fs');

console.log('@from-static/generator-hello-world: Configuring "out" directory.')
fs.rmSync('./out', { recursive: true });
fs.mkdirSync('./out');

let _STATIC = {};

try {
console.log('@from-static/generator-hello-world: Reading "static.json" file.')
_STATIC = require('./static.json');
} catch (e) {
console.log('@from-static/generator-hello-world: Error reading "static.json" file.');
}

fs.writeFileSync('./out/index.html', _STATIC?.data?.message || '');

console.log('@from-static/generator-hello-world: Done!')
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@from-static/generator-hello-world",
"version": "1.0.0",
"description": "An example generator for use in the static Application Design Approach",
"scripts": {
"build": "node index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/from-static/generator-hello-world.git"
},
"author": "Joe Bottigliero",
"license": "MIT",
"bugs": {
"url": "https://github.com/from-static/generator-hello-world/issues"
},
"homepage": "https://github.com/from-static/generator-hello-world#readme"
}

0 comments on commit 8f16dd2

Please sign in to comment.