diff options
| author | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2024-10-24 19:50:15 -0500 |
|---|---|---|
| committer | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2024-10-24 19:50:15 -0500 |
| commit | 015932a62e400e7d595777b6b29f64e60ae12943 (patch) | |
| tree | fe079726bcf33ba5f7430d6d96ac7e42644d9197 /src | |
| parent | f824bbcca25b4caaef8023cf36efaaed37e7257f (diff) | |
changes
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile | 18 | ||||
| -rw-r--r-- | src/example.md | 16 | ||||
| -rwxr-xr-x | src/gen/gen_index.sh | 11 | ||||
| -rwxr-xr-x | src/make_index.md.sh | 19 |
4 files changed, 35 insertions, 29 deletions
diff --git a/src/Makefile b/src/Makefile index c60678a..7c7af1f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,28 +1,26 @@ -BUILD_DIR = _build +BUILD_DIR ?= build -MARKDOWNFILES != find md/ -type f -name "*.md" +MARKDOWNFILES = $(wildcard md/*.md) HTMLTARGETS = $(MARKDOWNFILES:md/%.md=$(BUILD_DIR)/stories/%.html) -$(BUILD_DIR)/stories/%.html: md/%.md +$(BUILD_DIR)/stories $(BUILD_DIR): + mkdir -p $@ + +$(BUILD_DIR)/stories/%.html: md/%.md | $(BUILD_DIR)/stories pandoc "$<" \ --standalone \ --embed-resources \ --template template.html \ -o "$@" -$(BUILD_DIR)/index.html: make_index.md.sh +$(BUILD_DIR)/index.html: gen/gen_index.sh | $(BUILD_DIR) bash $< | pandoc \ --standalone \ --embed-resources \ --template template.html \ -o "$@" -make_dirs: - mkdir -p $(BUILD_DIR)/stories - all: make_dirs $(HTMLTARGETS) $(BUILD_DIR)/index.html -clean: - rm -rf $(BUILD_DIR) +.PHONY: make_dirs all -.PHONY: clean make_dirs all up diff --git a/src/example.md b/src/example.md new file mode 100644 index 0000000..667cdc0 --- /dev/null +++ b/src/example.md @@ -0,0 +1,16 @@ +--- +title: this is the title +--- + +some + +text + +asdf +asdf +asd +fas +df +sadf +sad +f diff --git a/src/gen/gen_index.sh b/src/gen/gen_index.sh new file mode 100755 index 0000000..516f594 --- /dev/null +++ b/src/gen/gen_index.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +file="---\ntitle: All Stories\n---\n" + +for i in md/*.md; do + title=$(sed -nE 's/^title: "?(.*)("?)$/\1/p' "$i") + no_ext=$(basename "$i" .md) + file+="\n- [$title](/stories/${no_ext}.html)" +done + +echo -e "$file" diff --git a/src/make_index.md.sh b/src/make_index.md.sh deleted file mode 100755 index 544b90c..0000000 --- a/src/make_index.md.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -links="--- -title: All Stories ---- - -" - -for i in md/*.md; do - title=$(grep '^title:' $i | tr -d '"' | sed -E 's/^title: (.*)$/\1/') - - no_ext=$(basename "${i%.*}") - link="- [$title](/stories/${no_ext}.html) -" - - links+="$link" -done - -echo "$links" |
