From: Kyle Bowman Date: Sat, 14 Dec 2024 15:58:55 +0000 (-0500) Subject: feat: make assets portable by copying into build X-Git-Url: https://git.rocketbowman.com/?a=commitdiff_plain;h=d569fc1cc98e0bfa2e7e6d1e06f3d6a102f4ae52;p=jetsam.git feat: make assets portable by copying into build --- diff --git a/.gitignore b/.gitignore index 95464d3..d402616 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.buildlist build/ src/ diff --git a/Makefile b/Makefile index 26fdbbc..f9d5c5c 100644 --- a/Makefile +++ b/Makefile @@ -1,41 +1,46 @@ -SRC_DIR := src +ASSETS_DIR := assets BUILD_DIR := build +SRC_DIR := src BUILD_LIST := $(shell find -L . -path './$(SRC_DIR)/**/*.md' | sed 's:./$(SRC_DIR):$(BUILD_DIR):g' | sed 's:\.md:\.html:g') -.PHONY: clean help index +.PHONY: all clean help help: @echo "Builds HTML files from MD files. Targets include:" @echo + @echo "all Builds the .buildlist and an index. (Top-level)" @echo "clean Removes build artifacts." @echo "help Prints this help message." - @echo "index Builds an index of all the files in the $(BUILD_DIR) directory. (Top-level)" - @echo "$(BUILD_DIR) Builds all the files defined in .buildlist." @echo ".buildlist Defines a list of all files to build. Paths may be relative." @echo " to this Makefile's directory. Paths should be on their own lines. You" @echo " may create this file manually or override the BUILD_LIST variable when" @echo " you invoke the make command. The default BUILD_LIST is created from MD files" @echo " found anywhere under the $(SRC_DIR) directory." -index: $(BUILD_DIR) - scripts/index.sh > build/index.html +all: build/index.html -$(BUILD_DIR): .buildlist +build/index.html: .buildlist xargs -n 1 make --no-print-directory < .buildlist + scripts/index.sh > build/index.html .buildlist: @echo $(BUILD_LIST) | tr ' ' '\n' > .buildlist -$(BUILD_DIR)/%.html: $(SRC_DIR)/%.md +$(BUILD_DIR)/$(ASSETS_DIR): $(SRC_DIR)/$(ASSETS_DIR) + mkdir -p $(BUILD_DIR)/$(ASSETS_DIR) + cp -rL $(SRC_DIR)/$(ASSETS_DIR)/* $(BUILD_DIR)/$(ASSETS_DIR) + +$(BUILD_DIR)/%.html: $(SRC_DIR)/%.md $(BUILD_DIR)/$(ASSETS_DIR) @mkdir -p $(dir $@) @pandoc \ --to=html5 \ --standalone \ + --toc=true \ --defaults=./defaults.yml \ --output=$@ $< \ --lua-filter=scripts/links-to-html.lua @echo "Building $@ from $<..." clean: - rm .buildlist + -rm .buildlist rm -rf $(BUILD_DIR) \ No newline at end of file diff --git a/defaults.yml b/defaults.yml index fc7a2d3..86d3076 100644 --- a/defaults.yml +++ b/defaults.yml @@ -1,6 +1,6 @@ from: markdown+wikilinks_title_before_pipe css: # ${.} is robust on build, but probably not for deployment - - ${.}/assets/css/normalize.css - - ${.}/assets/css/space-sakura.css + - ../assets/css/normalize.css + - ../assets/css/space-sakura.css diff --git a/scripts/index.sh b/scripts/index.sh index 46ac3ad..404fbc5 100755 --- a/scripts/index.sh +++ b/scripts/index.sh @@ -67,5 +67,5 @@ make_boilerplate(){ ######## # MAIN # ######## -FILES="$(find "$BUILD_DIR" -type 'f' -not -name "*index.html" | sort)" +FILES="$(find "$BUILD_DIR" -type 'f' -and -name '*.html' -not -name "*index.html" | sort)" make_boilerplate "$(make_ul "$FILES")"