+5
-4
| #!/usr/bin/env node | ||
| 'use strict'; | ||
| const tinyjam = require('./index.js'); | ||
| const {version} = require('./package.json'); | ||
| const {performance} = require('perf_hooks'); | ||
| import tinyjam from './index.js'; | ||
| import {readFileSync} from 'fs'; | ||
| import {performance} from 'perf_hooks'; | ||
| const version = JSON.parse(readFileSync(new URL('./package.json', import.meta.url))).version; | ||
| if (process.argv.length < 3) { | ||
@@ -9,0 +10,0 @@ console.log(`tinyjam v${version}`); |
+8
-12
@@ -1,13 +0,9 @@ | ||
| 'use strict'; | ||
| import fs from 'fs'; | ||
| import {join, basename, dirname, extname, relative} from 'path'; | ||
| const fs = require('fs'); | ||
| const {join, basename, dirname, extname, relative} = require('path'); | ||
| import {compile} from 'yeahjs'; | ||
| import fm from 'front-matter'; | ||
| import marked from 'marked'; | ||
| import yaml from 'js-yaml'; | ||
| const {compile} = require('yeahjs'); | ||
| const fm = require('front-matter'); | ||
| const marked = require('marked'); | ||
| const yaml = require('js-yaml'); | ||
| module.exports = tinyjam; | ||
| const defaultOptions = { | ||
@@ -20,3 +16,3 @@ log: false, | ||
| function tinyjam(src, dest = src, options = {}) { | ||
| export default function tinyjam(src, dest = src, options = {}) { | ||
| options = Object.assign({}, defaultOptions, options); | ||
@@ -120,3 +116,3 @@ | ||
| log(`read ${shortPath}`); | ||
| data[name] = createCtx(rootPath, yaml.safeLoad(fs.readFileSync(path, 'utf8'))); | ||
| data[name] = createCtx(rootPath, yaml.load(fs.readFileSync(path, 'utf8'))); | ||
@@ -123,0 +119,0 @@ } else if (ext === '.ejs') { |
+13
-8
@@ -5,20 +5,22 @@ { | ||
| "main": "index.js", | ||
| "type": "module", | ||
| "exports": "./index.js", | ||
| "bin": { | ||
| "tinyjam": "./cli.js" | ||
| }, | ||
| "version": "0.2.0", | ||
| "version": "0.3.0", | ||
| "author": "Vladimir Agafonkin", | ||
| "license": "ISC", | ||
| "dependencies": { | ||
| "front-matter": "^3.1.0", | ||
| "js-yaml": "^3.13.1", | ||
| "marked": "^1.0.0", | ||
| "front-matter": "^4.0.2", | ||
| "js-yaml": "^4.0.0", | ||
| "marked": "^1.2.7", | ||
| "yeahjs": "^0.2.0" | ||
| }, | ||
| "devDependencies": { | ||
| "dir-compare": "^2.3.0", | ||
| "eslint": "^7.0.0", | ||
| "dir-compare": "^2.4.0", | ||
| "eslint": "^7.17.0", | ||
| "eslint-config-mourner": "^3.0.0", | ||
| "rimraf": "^3.0.2", | ||
| "tape": "^5.0.0" | ||
| "tape": "^5.1.1" | ||
| }, | ||
@@ -32,3 +34,3 @@ "scripts": { | ||
| "parserOptions": { | ||
| "ecmaVersion": 2018 | ||
| "ecmaVersion": 2020 | ||
| } | ||
@@ -39,2 +41,5 @@ }, | ||
| ], | ||
| "engines": { | ||
| "node": ">= 12.17.0" | ||
| }, | ||
| "keywords": [ | ||
@@ -41,0 +46,0 @@ "static", |
+10
-6
@@ -116,3 +116,3 @@ <h1 align="center">tinyjam</h1> | ||
| ```js | ||
| const tinyjam = require('tinyjam'); | ||
| import tinyjam from 'tinyjam'; | ||
@@ -127,2 +127,4 @@ tinyjam(sourceDir, outputDir, { | ||
| Note that the project only supports Node v12.17+. | ||
| ## FAQ | ||
@@ -132,4 +134,6 @@ | ||
| I wanted to add some templating to my personal static websites like [my band's album page](https://rain.in.ua/son/en) (currently in pure HTML/CSS/JS) to make them easier to maintain, but never found a static site generator that would be simple and unobtrusive enough for my liking — not requiring meticulous configuration, special folder structure, reading through hundreds of documentation pages, bringing in a ton of dependencies, or making you learn a new language; and be flexible enough to make multilingual websites without plugins and convoluted setup. | ||
| I wanted to add some templating to my personal static websites to make them easier to maintain (e.g. [my band's album page](https://rain.in.ua/son/en), which is pure HTML/CSS/JS), but never found a static site generator that would be simple and unobtrusive enough for my liking. | ||
| A tool I envisioned would not involve meticulous configuration, special folder structure, reading through hundreds of documentation pages, bringing in a ton of dependencies, or making you learn a new language. At the same time, it would be flexible enough to make multilingual websites without plugins and convoluted setup. | ||
| Ideally, I would just rename some `html` files to `ejs`, move some content to Markdown files, add light templating and be done with it. So I decided to build my own minimal tool for this, but will be happy if anyone else finds it useful. | ||
@@ -143,7 +147,7 @@ | ||
| Pretty fast. I didn't see a point in benchmarking because most of the time is spent parsing Markdown/YAML and rendering EJS anyway, but corresponding dependencies (`marked`, `js-yaml`, `ejs`) are very well optimized. | ||
| Pretty fast. I didn't see a point in benchmarking because most of the time is spent parsing Markdown/YAML and rendering EJS anyway, but corresponding dependencies (`marked`, `js-yaml`, `yeahjs`) are very well optimized. | ||
| #### Why EJS for templating, and can I use another templating system? | ||
| EJS is also an extremely simple, minimal system, and it allows you to use plain JavaScript for templates, making it pretty powerful with almost no learning curve. No plans to support other template engines. | ||
| EJS is also an extremely simple, minimal system, and it allows you to use plain JavaScript for templates, making it pretty powerful with almost no learning curve. To make it even faster, I crafted my own implementation ([yeahjs](https://github.com/mourner/yeahjs)). No plans to support other template engines. | ||
@@ -177,4 +181,4 @@ #### How do I make a reactive single-page app with dynamic routing, hydration, bundle splitting and service worker caching? | ||
| ```js | ||
| const tinyjam = require('tinyjam'); | ||
| const {highlight} = require('highlight.js'); | ||
| import tinyjam from 'tinyjam'; | ||
| import {highlight} from 'highlight.js'; | ||
@@ -181,0 +185,0 @@ tinyjam(sourceDir, outputDir, { |
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
15351
1.82%184
2.22%Yes
NaN132
-1.49%4
33.33%+ Added
+ Added
+ Added
- Removed
Updated
Updated
Updated