1.0.4 • Published 2 years ago

my-first-ssg-1 v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

My-First-SSG

A Static Site Generator(SSG) for OSD600

This repo introduces a JavaScript program that convert .txt file into a HTML file

Installation

npm i yargs

After installation of yargs. Make sure you have your js file to run.

If you don't have it, you can create a js file by using the command: touch test.js

Commands

server.js --input 'filename'

For Example: You can simply run the program by the command:

node test.js -i 'Silver Blaze.txt'

Which will generate a HTML file for the 'Silver Blaze.txt' file into the /dist folder.

Or

node test.js -i .\Sherlock-Holmes-Selected-Stories\

Which will generate a few of HTML files for the Sherlock-Holmes-Selected-Stories directory into the /dist folder.

Options

Options:

  -h, --help     Show help                                             [boolean]
  -v, --version  Show version number                                   [boolean]
  -o, --output                           [string] [required] [default: "./dist"]
  -l, --lang     generate the lang attribute  [string] [required] [default: "."]
  -i, --input    convert .txt file to html file              [string] [required]

Optional Features

  • Get the title of the .txt file and put the name of the title intotitle, also put it into h1 that inside body

  • Personal footer

  • Convert a MD file to a HTML file

  • A feature for languagein <html>

Prettier

  • npm run prettier is the command to run the prettier command with the main js file -- server.js.
  • npm run prettier-check is the command to check if the main js file -- server.js run the prettier or not.

Eslint

  • npm run eslint is the command to run the eslint command with main js file -- server.js to check the coding syntax.
  • npm run eslint-fix is the command to fix some command or basic error for the server.js, and return warnings for what can't be fixed automatically.

.Vscode

  • extensions.json Specify the static extensions. For helping the cooperator to install servals recommended extensions.
  • settings.json Specify settings for the editor. Ensure that whenever the cooperator saves a file, the program would format the code using the prettier extension.

Testing

  • npm run test is the command to run all testing files of the program(currently only have 1 test file).
  • npm run test .\htmlGenerator.test.js is the command to run the specific testing functions in the htmlGenerator.test.js.

Watch

  • npm run test:watch is the command to run the test runner watch. It will show a list of options for testing:
No tests found related to files changed since last commit.
Press `a` to run all tests, or run Jest with `--watchAll`.

Watch Usage
 › Press a to run all tests.
 › Press f to run only failed tests.
 › Press p to filter by a filename regex pattern.
 › Press t to filter by a test name regex pattern.
 › Press q to quit watch mode.
 › Press Enter to trigger a test run.

And you can type in 'a' or 'f' or 'p' or 't' or 'q' to selection an option. Also, you can press to trigger a test run.

Coverage

  • npm run coverage is the command to run the Code Coverage Analysis, it will run the tests generate a coverage report to the user. It will have a table similar to this:
------------------|---------|----------|---------|---------|-------------------
File              | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
------------------|---------|----------|---------|---------|-------------------
All files         |     100 |      100 |     100 |     100 |                   
 htmlGenerator.js |     100 |      100 |     100 |     100 |                   
------------------|---------|----------|---------|---------|-------------------

Index HTML(DEMO)

My-First-SSG-Example

License

MIT License

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.0

2 years ago