Commandline Static Site Generating tool that helps you produce .html
from .txt
or .md
files
The tool is before its first release but comes up with these features already:
- accept
.txt
or.md
file to generate a.html
file - accept folders to generate
.html
files from.txt
and.md
files - goes through all the child directories of the input folder to generate the desired files
- output folder can be externally provided to get the generated files at desired location. if not provided, the output is generated in a folder set as default output folder
- stylesheet can be externally provided in either link form or file form to add style to the webpages. If not provided, the no stylesheet is added to the webpages
- detects title and paragraph of the text file to give accurate tags in the webpage and sets title to the webpage
- if a folder is provided, a new file called
index.html
is generated which contains link to all the files just generated - program exits with code 1 if something unexpected happens; if everything is working it exits with code 0
- can generate document for any language under MDN WebDocs
Option | Function |
---|---|
-h, --help | shows all the options currently active |
-v, --version | output the version number |
-i, --input <type> | takes input of the file/folder |
-o, --output <type> | takes destination folder location |
-s, --stylesheet <type> | takes any stylesheet that needs to be added to the html |
-c, --config <type> | takes a JSON file with options |
This option shows all the currently available options that can be used. It can be used in two ways -h
or --help
.
Example:
$ commandline-ssg -h
This option shows the current version of the tool. It can be used in two ways -v
or --version
.
Example:
$ commandline-ssg -v
This option takes in the file/folder that needs to be converted to generate the static site. It converts .txt
file to .html
file. It can be used in two ways, -i
or --input
.
Example:
If the input element is a file
$ commandline-ssg -i foo.txt
If the input element is a folder
$ commandline-ssg -i folder
This option takes in the folder name where the user wants the final generated file to be. If this option is not provided, its default value dist
is set for the folder output. It can be used in two ways, -o
or --output
.
Example:
$ commandline-ssg -i foo.txt -o newDist
This option takes in the stylesheet that adds style to each html file generated. It can be passed as either link or file. If it is not provided, no stylesheet is added to the webpages. It can be used in two ways, -s
or --stylesheet
.
Example:
$ commandline-ssg -i foo.txt -s https://cdnjs.cloudflare.com/ajax/libs/tufte-css/1.8.0/tufte.min.css
This option reads a given JSON file for the above options and applies the options to the resulting HTML. This will overwrite other commandline argument options. If an option is not provided in the JSON it will result to the default value. It can be used in two ways, -c
or --config
.
Example:
$ commandline-ssg -c config.json
For instance, to generate html from a folder, TextFolder
, in the project root directory in a new folder HTMLFolder
, and add https://cdnjs.cloudflare.com/ajax/libs/tufte-css/1.8.0/tufte.min.css
URL stylesheet, we can write the following command:
$ commandline-ssg -i TextFolder -o HTMLFolder -s https://cdnjs.cloudflare.com/ajax/libs/tufte-css/1.8.0/tufte.min.css
It will do the following:
If the TextFolder has one file foo.txt with these text
A Smart title
A short paragraph.
Another short paragraph.
a foo.html file will be generated in the HTMLFolder with the https://cdnjs.cloudflare.com/ajax/libs/tufte-css/1.8.0/tufte.min.css stylesheet.
<!doctype html>
<html lang="en">
<head><meta charset="utf-8">
<title>A Smart title</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tufte-css/1.8.0/tufte.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1>A Smart title</h1>
<p>A short paragraph.</p>
<p>Another short paragraph.</p>
</body></html>
commandline-ssg cli