NodeJs – Static site generator Release 0.1

mh-ssg

mh-ssg is a simple static site generator that allows users to convert text files into HTML files. The tool is written in NodeJs with 4 main features. New features will be added on later. Visit the repo on Github.

Installat…


This content originally appeared on DEV Community and was authored by Minh Hang Nguyen

mh-ssg

mh-ssg

mh-ssg is a simple static site generator that allows users to convert text files into HTML files. The tool is written in NodeJs with 4 main features. New features will be added on later. Visit the repo on Github.

Installation

  1. Clone the repo
  2. Install Node
  3. Redirect to project directory
  4. Install mh-ssg globally with npm i -g .

Features

  1. Creates HTML files from specified file/directory
  2. Allows users to specify an output folder or use folder dist as default
  3. Allows users to specify a stylesheet
  4. Detects and sets the title of the file into the title and h1 of the HTML file (if any)

Usage

To use the tool, users can specify 3 options

-i --input

The tool accepts input as a single text file or or directory. If a directory is specified, the tool will ignore other file types and only process text files.

mh-ssg -i <file.txt>
mh-ssg -i <directory>
-o --output

Users can specify an output directory where they want to save the HTML files to. If the specified directory is not found, the tool will display an error message and will not process the input file. If no directory is given, the tool will use the default ./dist/

mh-ssg -i <file.txt> -o <directory>
-s --stylesheet

To use a custom stylesheet, simply pass in the link to the stylesheet to stylesheet option

mh-ssg -i <file.txt> -s <link-to-stylesheet>

Example

mh-ssg -i file.txt -o folder -s https://cdn.jsdelivr.net/npm/water.css@2/out/water.css

will convert

./file.txt
Silver Blaze


I am afraid, Watson, that I shall have to go,” said Holmes, as we
sat down together to our breakfast one morning.

“Go! Where to?”

“To Dartmoor; to King’s Pyland.”

into

./folder/file.html
<!doctype html>
<html lang="en" dir="ltr">
<head>
<title>Silver Blaze</title>
<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">


</head>
<body>
<h1>Silver Blaze</h1>

<p>I am afraid, Watson, that I shall have to go,” said Holmes, as we sat down together to our breakfast one morning.</p>

<p>“Go! Where to?”</p>

<p>“To Dartmoor; to King’s Pyland.”</p>

</body>
</html>


This content originally appeared on DEV Community and was authored by Minh Hang Nguyen


Print Share Comment Cite Upload Translate Updates
APA

Minh Hang Nguyen | Sciencx (2021-09-16T14:31:32+00:00) NodeJs – Static site generator Release 0.1. Retrieved from https://www.scien.cx/2021/09/16/nodejs-static-site-generator-release-0-1/

MLA
" » NodeJs – Static site generator Release 0.1." Minh Hang Nguyen | Sciencx - Thursday September 16, 2021, https://www.scien.cx/2021/09/16/nodejs-static-site-generator-release-0-1/
HARVARD
Minh Hang Nguyen | Sciencx Thursday September 16, 2021 » NodeJs – Static site generator Release 0.1., viewed ,<https://www.scien.cx/2021/09/16/nodejs-static-site-generator-release-0-1/>
VANCOUVER
Minh Hang Nguyen | Sciencx - » NodeJs – Static site generator Release 0.1. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/09/16/nodejs-static-site-generator-release-0-1/
CHICAGO
" » NodeJs – Static site generator Release 0.1." Minh Hang Nguyen | Sciencx - Accessed . https://www.scien.cx/2021/09/16/nodejs-static-site-generator-release-0-1/
IEEE
" » NodeJs – Static site generator Release 0.1." Minh Hang Nguyen | Sciencx [Online]. Available: https://www.scien.cx/2021/09/16/nodejs-static-site-generator-release-0-1/. [Accessed: ]
rf:citation
» NodeJs – Static site generator Release 0.1 | Minh Hang Nguyen | Sciencx | https://www.scien.cx/2021/09/16/nodejs-static-site-generator-release-0-1/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.