DEV Community

gus
gus

Posted on

GAS SSG

image

This week I wrote a Static Site Generator in C++ that takes a text file or folder structure and generates HTML files based on any text files found within. It's been 8 months since I've written any code so it was a big undertaking getting back into it, but it felt good to code in C++ again. There's a lot I could've written more efficiently, some code duplication etc. but it gets the job done and got me working with classmates to solve some problems open source style.

The SSG comes in .cpp form and should be compiled using C++17 to support the recursive file system searching feature from . It accepts command line arguments -i or --input to specify an input file or folder structure, -h or --help for info on the commands to use, and -v or --version for version information.

image

If there's a title with 2 blank lines following it, GAS will make this the title of the page. This line will also be be made an <h1> element.

image

The blocks of text are split up into <p> tags if a blank line is found between them. That's about all there is to it, you can check out the repo here and a sample HTML page generated here.

Discussion (0)