Holy moly. I just want to take a Markdown file, a simple HTML template file, and generate some webpages. Is that too much to ask?? All the template engines and SSGs are trying to give me everything and the kitchen sink, which I don't need. Please tell me I won't have to write this myself...

Problem solved, in a very UNIXy way!

pages=`cat ./pages.txt`
for page in $pages;
$(which comrak) $page.md > $page.temp.html
cat header.template $page.temp.html footer.template > $page.html
rm *.temp.html

Show thread

pages.txt holds a newline separated list of the page names that I want to generate (index, codeofconduct, etc). We iterate over this list, using comrak (lib.rs/crates/comrak) to convert the MD to HTML, which is dumped in a temp file. The temp file is then `cat`ed together with the header and footer templates, which are just the top and bottom pieces of an HTML file.

omg I'd totally forgotten about `printf`! If nothing else, trying to get this tilde server off the ground has helped _me_ get better at doing things the UNIX way.

Show thread
Sign in to participate in the conversation
The Cabal

This is a server created by Jahziel Villasana (aka hapax). He's not sure what he's going to use it for yet...