From 015932a62e400e7d595777b6b29f64e60ae12943 Mon Sep 17 00:00:00 2001 From: Collin Williams <96917990+bluedragon1221@users.noreply.github.com> Date: Thu, 24 Oct 2024 19:50:15 -0500 Subject: changes --- flake.nix | 2 +- src/Makefile | 18 ++++++++---------- src/example.md | 16 ++++++++++++++++ src/gen/gen_index.sh | 11 +++++++++++ src/make_index.md.sh | 19 ------------------- 5 files changed, 36 insertions(+), 30 deletions(-) create mode 100644 src/example.md create mode 100755 src/gen/gen_index.sh delete mode 100755 src/make_index.md.sh diff --git a/flake.nix b/flake.nix index 2eb2de1..ca9af0d 100644 --- a/flake.nix +++ b/flake.nix @@ -31,9 +31,9 @@ devShells.${system}.default = pkgs.mkShell { buildInputs = with pkgs; [ pandoc - ripgrep http-server shellcheck + checkmake gnumake ]; }; 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" -- cgit v1.3.1