Hello-World

Blogging’s cool, right? :3c
Up Home
Updated

Hello world!

This is a blog post mainly for the sake of making sure the Makefile can generate this correctly. I don’t have anything interesting to say today.

I might, sometimes, post a ramble. There will be no theme, or rhyme or reason - just braindumping. Sorted by filename, so arbritrarily in order of posting, but I could break that rule by just having a different number.

For the curious, here’s the makefile that generates this site:


OUT_DIR := ./static
PAGES_DIR := ./pages

INPUT := $(shell find $(PAGES_DIR) -type f -name '*.md')
$(info INPUT files: $(INPUT))

resources: $(wildcard ./pages/resources/*)
    cp -r $^ $(OUT_DIR)/

$(OUT_DIR)/%.html: $(PAGES_DIR)/%.md ./pages/templates/template.html
    $(info Converting: $< -> $@)
    @mkdir -p $(dir $@)
    @sed "s/\$2025-01-10/$$(date +%Y-%m-%d)/g" $< | \
    pandoc -s --css /reset.css --css /style.css --template=pages/templates/template.html | \
    awk -f add_copy_buttons.awk > $@


all: resources $(INPUT:$(PAGES_DIR)/%.md=$(OUT_DIR)/%.html)

clean:
    @rm -rf $(OUT_DIR)/*

.PHONY: all clean resources

It eats ./pages/**/*.md and outputs ./static/**/*.html (preserving folder structure). I’ll stick the template under public if you want to copy my homework in its entirety. Caddy generates the index page on /ramblings using another template, also available in public. It’ll ony do that for directories that don’t contain a user-defined index page.

The AWK section is for adding little “Copy” buttons to any codeblocks on the page, sequentially. Here’s the script:


BEGIN { counter=1 }
{
        if ($0 ~ /<pre><code/) {
                print "<pre><button class=\"block-copy\" onClick=\"copyBlock('code-block-" counter "')\">Copy</button>";
                sub(/<pre><code([^>]*)>/, "<code id='code-block-" counter "'>");
                print;
                counter++;
        } else {
                print;
        }
}