70 lines
2.5 KiB
Makefile
70 lines
2.5 KiB
Makefile
# if someone can come up with something better then i'd appreciate that.
|
|
# For now this is a bit complex but it gets the job done.
|
|
# It's still a ticking time bomb and I hope we can fix it before it explodes.
|
|
# Even if it explodes, it won't be that big of a deal.
|
|
|
|
# Input dir describes the directory that has the markdown we want to convert
|
|
# Static dir describes the directory that has files we should simply copy as-is
|
|
# Output dir describes the directory that we want our final result to be in.
|
|
INPUT_DIR=content
|
|
STATIC_DIR=static
|
|
OUTPUT_DIR=output
|
|
UTILS_DIR=utils
|
|
|
|
# The pandoc template to use
|
|
TEMPLATE=$(UTILS_DIR)/template.html
|
|
|
|
# The pandoc lua filter to use
|
|
# The language code and file extension will be appended later
|
|
FILTER=$(UTILS_DIR)/link-filter.
|
|
|
|
## You should not need to change anything beyond this line
|
|
|
|
|
|
|
|
STATIC=$(patsubst $(STATIC_DIR)/%,$(OUTPUT_DIR)/%,$(shell find $(STATIC_DIR) -type f))
|
|
OUTPUT=$(patsubst $(INPUT_DIR)/%.md,$(OUTPUT_DIR)/%/index.html,$(shell find $(INPUT_DIR) -type f))
|
|
|
|
# The last one is for the autogenerated authors thing.
|
|
site: $(OUTPUT) $(STATIC) $(OUTPUT_DIR)/authors/index.html
|
|
|
|
# This generates the authors file.
|
|
$(OUTPUT_DIR)/authors/index.html: $(UTILS_DIR)/authors.md
|
|
mkdir -p $(dir $@)
|
|
pandoc --from markdown+smart+yaml_metadata_block+auto_identifiers -V lastmod="$(shell git log --follow --format=%ad --date default $< | tail -1)" --to html --template $(TEMPLATE) $< -o $@
|
|
|
|
# Generate normal markdown
|
|
$(OUTPUT_DIR)/%/index.html: $(INPUT_DIR)/%.md $(TEMPLATE)
|
|
mkdir -p $(dir $@)
|
|
pandoc --from markdown+smart+yaml_metadata_block+auto_identifiers -V lastmod="$(shell git log --follow --format=%ad --date default $< | tail -1)" --lua-filter=$(FILTER)$(shell echo $@ | cut -d / -f 2).lua --to html --template $(TEMPLATE) $< -o $@
|
|
@# Pandoc indenting causes too many issues. From https://stackoverflow.com/a/68633114
|
|
sed -i 's/^\s*<span/<span/g' "$@"
|
|
sed -i 's/^\s*\([^<]\)/\1/g' "$@"
|
|
$(eval DIRNAME != dirname $(subst index.html,,$@))
|
|
@if [ -d "$(DIRNAME)/_index/" ]; then \
|
|
mv $(DIRNAME)/_index/index.html $(DIRNAME); \
|
|
rmdir $(DIRNAME)/_index/; \
|
|
fi
|
|
|
|
# Copy straight from static dir
|
|
$(OUTPUT_DIR)/%: $(STATIC_DIR)/%
|
|
mkdir -p $(dir $@)
|
|
cp $< $@
|
|
|
|
# Remove everything in the output dir
|
|
clean:
|
|
if [ -d "$(OUTPUT_DIR)" ]; then \
|
|
rm -r "$(OUTPUT_DIR)"; \
|
|
fi
|
|
|
|
## These rules are not used for wiki generation at all...
|
|
# So don't use them!
|
|
test:
|
|
cd $(OUTPUT_DIR); python3 -m http.server 9000
|
|
|
|
mon:
|
|
@echo "find $(INPUT_DIR)/ $(STATIC_DIR)/ $(dir $(TEMPLATE)) -type f | entr make"
|
|
|
|
.PHONY: clean test
|
|
|