DEV Community

Alexander Samaniego
Alexander Samaniego

Posted on

DPS909 Blog: SSG Release 0.1

I created my static site generator tool using JavaScript and Node.js. I was already familiar with JavaScript and Node.js but I thought I could improve my knowledge by working with it more often.

Link to repository: https://github.com/alexsam29/ssg-cli-tool

Overview

This tool allows a user to specify a text (.txt) file path or a directory path as an argument in the command-line. A HTML file will then be created based on the specified text file. If a directory was specified, then HTML files will be created for every .txt file in the directory.

How to Use

In order to start using this tool, a recent version of Node.js must be downloaded and installed on your local machine.

Step-by-step

  1. Clone or download the repository from GitHub to your local machine. Remember the file location!

  2. Open a terminal or command window and move to the directory where the repository was downloaded to.

  3. Before moving forward make sure to run the command:

    npm install -g

    to ensure that all npm packages are installed.

  4. Start using the tool by inputting the path of a text file or folder using the -i/--input option. For example:

    ssg -i fileOrFolder_path

  5. The file specified will be added to the 'dist' directory. If it is a directory, all text files will be converted to HTML and added to the same directory. An index.html file will also be created with links to all HTML files generated.

  6. [OPTIONAL] You can specify the directory where you want to output the HTML files by using the -o/--output option. For example:

    ssg -i file_path -o directoryPath

If the directory does not exist, a new one will be created. If it does, then the contents will be erased and the new HTML files will be added.

Final output example: https://alexsam29.github.io/ssg-cli-tool/

Options

Options include:

  • -h/--help: This will output a list of all available options
  • -v/--version: This will output the name of the tool, version number and author name.
  • -i/--input: The main function of this tool. Convert text file(s) to HTML by specifying the file/folder path.
  • -o/--output: Specify the directory to add HTML files to.

Additional Features Implemented

In addition to the main requirements of the release, I have also added 3 of the optional requirements.

  • The title is parsed from the input files and used to populate the tag and added to the top of the .
  • As described above, I implemented the option for the user to specify the output directory with -o/--output.
  • An index.html page is created when the user inputs a folder path. This file contains links to each of the generated HTML files.

Top comments (0)