So for todays node cli project I started working on a basic static site generator, one of many project ides of node cli tool examples. The project makes use of the npm package known as marked which can be used to parse markdown files into html, as well as some of my other node cli projects such as nc-walk that make part of my node cli tools repository project. This static site generator might not really be of production quality as of yet, but if I do put more time into this project I am sure it will get there.
this is a post on the nc-ssg command for my node cli tools project. I will not be getting into the full depth of the project as a whole here, but I will say that it is a project that is a collection of node cli tools that can be used to create and maintain a website.
In the bin folder of the node cli tools project I creates a folder called ssg. This folder will contain the main file that will be called when the nc-bin command is called. In this file I am using yargs to parse options that are passed when calling the command.
This folder is a common folder that I have for all the commands of my node_cli_tools project. some commands might have more that one sub command and although that is not yet the case for nc-ssg, it might be the case at some point in the future for this one if I do continue working on this project. So far there is a default command, and a gen command which is short for generate. Future sub commands might be something like watch, which will automatically generate each time changes are made t the sites content.
Here I have just the logic for the default command that for now just logs to the console how to generate a site folder.
Here I have the logic for the sub command that will be used to generate a public folder with the posts and theme of a site folder that was created with the nc-init command.
The script requires in another gen.js file that is in the lib folder of this command, that is where I have most of my logic that composes the ssg.
So with some commands I might have a lib folder that is local to the folder of the command in the bin folder. This local lib folder is where I might park all kinds of files that are close to the command, rather than modules that might be used by more that one command in the project. Here I have a file that is used with my walk.js module to generate posts, as well as a gen.js file that contains the bulk of the logic for the static site generator at this time.
Here I have the file that exports a method that will be used to generate each page for each blog post in the _posts folder of the site folder that was created with the nc-init command. This method is used with my walk.js module that is in the shared folder of the node_cli_tools project.
Here I have the current state of gen.js of the nc-ssg command. I am making use of ejs as a template system that is one of the npm packages that I have made as part of the stack for node_cli_tools.