DEV Community

cychu42
cychu42

Posted on

Project: Static Site Generator

What is it?
Recently, I’m working a static site generator using JavaScript . What it does is that it takes TXT files to convert into HTML web pages. You can find it here. I name it the TXT-to-HTML Static Site Converter...Yeah, I never claim to be good with names. It's a bit of struggle between being practical and creative. I use the minimist module to handle options for the program.

Requirment
You first need to have Node.js installed. After downloading this program, run command "npm i" or "npm install" in command line while inside the program's directory to install required all npm package(s).

Usage
You need to supply TXT files to convert into HTML file(s) of the same names.
I included a few sample test files in the "test_files" folder.
This program is run by entering commands in command line, like cmd or PowerShell.
Use --input or -i to tell the program the path to a TXT file or a folder with TXT file(s), and it will convert them into HTML files in 'dist' folder. If the dist folder doesn't exist at the current directory, one will be created by the program. If the dist folder exist, it will be deleted and recreated to provide only the latest output.
Example: node SSC -i ./test_files

If you path has any space for a file or folder name, please use '' around the name(s).
Example: node SSC -i ./'a folder with space in the name'

Other options:
--version or -v
This option provides program name and its version.

--output or -o
This option specifies an output directory instead of the default dist folder. If the directory is invalid, output directory is set back to the default.
For safety reason, any directory specified by this option is never deleted by the program, unlike the default behaviour.
Example: -o ./myFolder

--stylesheet or -s
This is to specify url of the style sheet to use in the HTML files.
Example: -s https://cdnjs.cloudflare.com/ajax/libs/tufte-css/1.8.0/tufte.min.css

--help or -h
This will show you the help guide.

Top comments (0)