sbs

A Simple Blogging System.
git clone https://git.sr.ht/~jbauer/sbs
Log | Files | Refs | README | LICENSE

commit e5b24b78d3561ac9c48b1f3d6598e0d43dcca8ea
parent 4bb58b92450d8c162b6335c4dc4b642087089018
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Tue, 22 Feb 2022 14:11:51 -0500

Make 'build' command explicit

Diffstat:
Msbs | 52+++++++++++++++++++++++++++-------------------------
1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/sbs b/sbs @@ -139,34 +139,36 @@ if [ "$1" = "genfeed" ]; then fi # Build the pages given as arguments -for file in "$@"; do - if [ -d "$file" ]; then - "$0" "$file"/* - continue - elif [ ! -f "$file" ]; then - printf "ERROR: %s does not exist.\n" "$file" - continue - fi - - fileName=$(basename "$file" .md) - subDir=$(dirname "$file" | sed "s/^content//") - mkdir -p "static/$subDir" +if [ "$1" = "build" ]; then + shift + for file in "$@"; do + if [ -d "$file" ]; then + "$0" "$file"/* + continue + elif [ ! -f "$file" ]; then + printf "ERROR: %s does not exist.\n" "$file" + continue + fi - printf "Creating: static%s/%s.html...\n" "$subDir" "$fileName" + fileName=$(basename "$file" .md) + subDir=$(dirname "$file" | sed "s/^content//") + mkdir -p "static/$subDir" - # Extract metadata from the markdown document - title=$(lowdown -X title "$file") - meta=$(lowdown -X summary "$file") + printf "Creating: static%s/%s.html...\n" "$subDir" "$fileName" - # Build and process the output document - lowdown $buildOptions "$file" \ - | cat "templates/header.html" - "templates/footer.html" \ - | sed -e "s/<title>.*<\/title>/<title>$title - $siteName<\/title>/" \ - -e "s/lang=\"\"/lang=\"$languageCode\"/" \ - -e "s/content=\"\"/content=\"$meta\"/" \ - > "static/$subDir/$fileName".html + # Extract metadata from the markdown document + title=$(lowdown -X title "$file") + meta=$(lowdown -X summary "$file") - printf "Created: static%s/%s.html\n" "$subDir" "$fileName" -done + # Build and process the output document + lowdown $buildOptions "$file" \ + | cat "templates/header.html" - "templates/footer.html" \ + | sed -e "s/<title>.*<\/title>/<title>$title - $siteName<\/title>/" \ + -e "s/lang=\"\"/lang=\"$languageCode\"/" \ + -e "s/content=\"\"/content=\"$meta\"/" \ + > "static/$subDir/$fileName".html + printf "Created: static%s/%s.html\n" "$subDir" "$fileName" + done +fi exit 0