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!

```
#!/bin/sh
pages=`cat ./pages.txt`
for page in $pages;
do
$(which comrak) $page.md > $page.temp.html
cat header.template $page.temp.html footer.template > $page.html
done
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.

Show thread
Follow

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.

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...