Makefile
The makefile behind the garden. Not claiming it is any good.
# surely theres a simpler glob syntax
garden-sources := $(shell find garden -name "*.md" -type f) garden/makefile.md garden/listing.md
garden-outs := $(patsubst garden/%.md,out/%.html,$(garden-sources))
static-sources := $(shell find static -type f)
static-outs := $(patsubst static/%,out/%,$(static-sources))
.PHONY: no-search all
# default target (`make`) excludes pagefind cause it's a little slow. `make all` to get it
no-search: $(garden-outs) $(static-outs)
all: no-search out/pagefind
garden/makefile.md: Makefile
mkdir -p $(@D)
'# Makefile\n\nThe makefile behind the [garden](garden). Not claiming it is any good.\n\n```makefile\n' > garden/makefile.md
printf
cat Makefile >> garden/makefile.md'\n```' >> garden/makefile.md
printf
# listing.md contains links to all files
garden-sources-no-listing := $(subst garden/listing.md,,$(garden-sources))
garden/listing.md: $(garden-sources-no-listing)
mkdir -p $(@D)
"# Listing\n\nAll files in my garden:\n\n" > garden/listing.md
printf $(basename $(subst garden/,,$(garden-sources-no-listing))) | sed "s/ /\n/g" | sort | uniq | sed -E "s/(.*)/\* [\1](\/\1)/g" >> garden/listing.md
echo
# create .html files from .md sources using pandoc
out/%.html: garden/%.md mytemplate.html filter.lua
mkdir -p $(@D)
$< -o $@ --template=mytemplate.html --lua-filter=filter.lua --mathml --wrap=preserve --highlight-style=kate
pandoc --from=markdown+autolink_bare_uris+raw_attribute
# copy static resources as-is
out/%: static/%
mkdir -p $(@D)
$< $@
cp
# run pagefind after creating all the html files
out/pagefind: $(garden-outs) $(static-outs)
npx -y pagefind --site out
.PHONY: clean serve open push
clean:
rm -rf ./out
serve:
miniserve -v out --index index.html
open:
start http://[::1]:8080
push:
git add .
"lazy commit"
git commit -m git push