Skip to content

RC-Lee/SiteGen

Repository files navigation

OSD-SiteGen

About

A basic Static Site Generator that converts .txt and .md files to .html files. Current release 1.0.0 on npm with the following features.

Features

  • Allows the user to specify an input file or input folder to be processed.
  • Allows the input to be a deep tree of files and folders, all .txt and .md files are recursively parsed.
  • Parsed titles (if any) from input .txt files.
  • Allows specification of a different output directory. If there's no directory specified, a dist folder will be created in the current working directory to store the generated html file(s).
  • Allows specification of a stylesheet through linking a stylesheet URL
  • Automatically generates an index.html file with relative links to each of the generated html files
  • Markdown support: Full markdown support through Remarkable
  • Supports parsing of config JSON files containing SSG options

Development

For interest in developments please read CONTRIBUTING.md

Installation

  1. Make sure you have npm installed
  2. Please make sure you have the latest version of Node ("v16.13.0")
  3. run the following in terminal or command line
npm install -g osd-sitegen

Head to any directory you wish for the default /dist folder to be generated in, then run the tool options below.

To uninstall run

npm uninstall -g osd-sitegen

Tool options

  -v, --version                              Displays tool name and current version
  -i, --input <file or directory name>       Designate an input file or directory
  -o, --output <directory name>              Designate an output directory, default ./dist
  -s, --stylesheet <stylesheet URL>          Link a stylesheet URL to the html
  -c, --config <file>                        Read and parse json properties from file as options.
  -h, --help                                 Lists all available options

Version option example

osd-sitegen -v or osd-sitegen --version will display the tool name and current version.

  Name:  osd-sitegen
  Version:  1.0.0

Help option example

osd-sitegen -h or osd-sitegen --help will list the tool options as listed above.


Input option examples

 osd-sitegen -i filename
 osd-sitegen --input "directory name"
 osd-sitegen -i relative-or-absolute-path-to-file-or-directory

This is the main processing option for the site generator tool.

In the case of spaces in file or directory names, quotation marks "" are needed to wrap around the name.


Output and Stylesheet option examples

Sample code for using output and stylesheet options below:

 sitegen -i filename -o relative-or-absolute-path-directory
 sitegen -i filename -s "stylesheet url"
 sitegen -i filename -o relative-or-absolute-path-directory -s "stylesheet url"
 sitegen -s "stylesheet url" -i filename -o relative-or-absolute-path-directory

In the case that an output directory isn't indicated or valid, the generator will create files in a default ./dist folder in the current working directory.


Markdown

The tool supports Markdown (.md) files with full Markdown support from Remarkable


Config file:

The tool supports .json config file

Usage

osd-sitegen -c config.json

Reading and parsing json properties as options for osd-sitegen Note: if -c exists, other options will be ignored.

Example.json

{
  "input": "./testfiles",
  "output": "./output",
  "stylesheet": "https://cdn.jsdelivr.net/npm/water.css@2/out/water.css",
  "lang": "en"
}

Special thanks to

Andrei Batomunkuev
Tue Nguyen

Generated Pages live example

Link to the example webpage