$title$

$body$

Notes for 2023-04-29

Working on my bash static site generator. Now working on generating the blog list on the home page. Extracting the title of the blog post from the h1 tag inside the post. Working on the date of the blog post also. At the moment, I wrap the date which is in normal YYYY-MM-DD format but is wrapped in a span element with id="date". Is there some kind of html semantic way of doing this? qApparently there is, i'm going to put it in a

<time>
element. with the datetime attribute set to the date in YYYY-MM-DD format.

Had to include an id="post-date" on the time element to make it easier for my static generator. Otherwise it would raise a warning if I included multiple time tags in my page, which is something I don't want to happen. Another limitation is that the post date must exactly equal

In the future I will need to improve this.

Noticed that html isn't showing inside a pre tag. I need to escape it somehow. Some pretty strange behaviour when trying to do this. Answer in this stack overflow works ok: https://stackoverflow.com/questions/5060452/put-a-bit-of-html-inside-a-pre-tag But for some reason I get {{content}} in the pre tag??? Must be something strange with my sed command It must be to do with this awk command:

awk -v var="$content" '{gsub(/{{content}}/,var)}1' template.html > "$output"

Switched to a sed command, and seeeeems to be working better, but then the CSS is gone? Really starting to wish I knew sed/awk better. You can prompt chatgpt as much as you want, but if you don't know what you're doing, first of all you don't know if chatgpt is just garbage and secondly, you can't modify what it's given you.

Ok now I have CSS but I just have "$content" on the page. learnt that sed -i means in place though. current command:

sed 's/{{content}}/$content/g' "template.html" > "public/posts/$filename.html"
For some reason instead of replacing {{content}} with the content of the post, it just replaces it with the string "$content" I think search and replace with sed is not going to work, I believe there is some content in the html post that is causing the search and replace command to exit? I just get: unterminated 's' command. I think an alternative is to chop the template into chunks and then insert the content in the middle.

And finally with this bit of code:

# get file contents including and up to the  tag
before=$(sed -n '1,//p' template.html)
after=$(sed -n '/<\/body>/,$p' template.html)

# insert the file contents between the  tags
echo "$before$content$after" > "public/posts/$filename.html"
        
This specific problem is solved.

To do:

In order to insert a back button, I have to change the way content is inserted. Instead of inserting the content between the body tags, I have to insert it after some other marker. I'm thinking just an html comment. Since I'm just using Bash, it should be a simple solution for now. It works fine.

Added home button. Updated title of blog post with a simple sed command. Blog posts are sorted by date. Now CSS improvements