Site Generation

Define Output Target

I'll add a fairly typical definition of a build directory. The creation of the directories will be done as needed in the recipes to support the nested structure.

SITE_DIR := site
clean: ; rm -rf $(SITE_DIR)
.PHONY: clean

Define an initial Pandoc Command

I'll build this up in pieces with an eye towards subsequent refinement.

Bibliography

Pandoc should handle the citation references, so I'll point it to the bibliography file exported from Zotero and activate citation processing.

The bibliography file should be copied to this repository so that it can be used by the CI build. This could theoretically also make use of a Zotero API but that seems overkill. This will subsequently be incorporated into another part of a workflow, since it also seems cleanest to not invoke it as part of a build where the source would not be available.

I'll define PANDOC_ARGS as extensible so I can tweak it as needed.

BIB_SRC     := ~/Documents/pod/bib.json
BIB_DST     := bib.json
PANDOC_ARGS += --bibliography $(BIB_DST)

$(BIB_DST): $(BIB_SRC); cp $(<) $(@)

Command

Produce a standalone file (rather than a fragment) with the bibiliography. Define this to be called with <input> and <output>.

The command itself is lazily expanded to allow for a more dynamic PANDOC_ARGS value.

PANDOC      := pandoc
PANDOC_ARGS += --standalone
PANDOC.cmd   = $(PANDOC) $(PANDOC_ARGS) --output $(2) $(1)  

Defaults

Use the defaults file for citation styling.

PANDOC_ARGS += --defaults pandoc.defaults

The filter written on January 27, 2025 will be added to the options.

PANDOC_ARGS += --filter LinkFixer.hs

Rule

The site directory should be populated using pandoc, so a pattern rule will be defined for that filtering.

The target directory will also be created here as needed.

$(SITE_DIR)/%.html: %.org
    mkdir -p $(@D)
    $(call PANDOC.cmd,$(<),$(@))

Files

Define the logical names. The types of files were originally split out to support an alternative structure, but it seems like a helpful organizational distinction.

JOURNALS = 2025/01/22 \
    2025/01/23 \
    2025/01/24 \
    2025/01/25 \
    2025/01/27 \
    2025/01/28 \
    2025/01/29 \
    2025/01/30 \
    2025/01/31 \
    2025/02/01 \
    2025/02/02 \
    2025/02/03 \
    2025/02/04 \
    2025/02/06 \
    2025/02/07 \
    2025/02/08 \
    2025/02/11 \
    2025/02/12 \
    2025/02/15 \
    2025/02/16 \
    2025/02/20 \
    2025/02/21 \
    2025/02/23 \
    2025/02/24 \
    2025/02/25 \
    2025/03/05

PAGES := index \
    site.mk \
    generate.mk \
    emacs_configuration \
    configuration.nix

Construct the Destinations

The destinations will be the union of the two file lists with SITE_DIR prepended and the .html extension added.

A PHONY target will be provided as an alias for all outputs.

OUTS :=$(call addsuffix,.html,$(call addprefix,$(SITE_DIR)/,$(JOURNALS) $(PAGES)))

site: $(OUTS)
.PHONY: site

Tarball Creation

Publishing to SourceHut is done using a tarball, so we'll create one out of the site directory with the prerequisite of the output files.

A build directory will be introduced for more ephemeral generated files (and to avoid potential cycles if the tarball were within its source).

The tarball is created within the site directory to make sure the relative paths are as desired. Redirection is used (rather than a file argument) to naturally define overwrite behavior using common constructs.

BUILD_DIR := build
$(BUILD_DIR): ; mkdir -p $(@)
clean-build: ; rm -rf $(BUILD_DIR)
clean: clean-build
.PHONY: clean-build

SITE_TAR := $(BUILD_DIR)/site.tar.gz

$(SITE_TAR): $(OUTS) | $(BUILD_DIR)
    cd $(SITE_DIR) && tar --create --gzip . > $(call abspath,$(@))

Publishing

Publishing is done using the hut executable per the SourceHut pages documentation.

HUT := hut
publish: $(SITE_TAR)
    $(HUT) pages publish -d www.mattwhipple.com $(<)
.PHONY: publish

Changelog

This file was started on January 25, 2025 which was focused on basic pandoc invocation with citation processing.

The filter and updated structure was introduced on January 28, 2025. I also added the copying of the bilbiography file at that point.