squeeze

A static site generator that can put the toothpaste back in the tube.
git clone https://git.mulligrubs.me/squeeze
Log | Files | Refs | README | LICENSE

commit 097448a354a2563615befe250304c9dbc2501583
parent a83303449b8b91b2bb08b1e1d47c14eeed66813f
Author: St John Karp <stjohn@fuzzjunket.com>
Date:   Sat, 30 May 2020 06:24:53 -0500

Handle files that have no headers

Fixed handling of files that have no headers. Only split the
file at the first new line if headers are detected. Created a
function for recombining the two.

Diffstat:
Msqueeze.sh | 25+++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/squeeze.sh b/squeeze.sh @@ -5,6 +5,18 @@ SOURCE_DIR=source SITE_PATH=$1 +combine_headers () { + read -d "" HTML + + if [ "$1" = "" ]; then + echo "$HTML" + else + echo "$1" + echo "" + echo "$HTML" + fi +} + # Copy everything that's not Markdown or HTML. # This will also create the folder structure for the destination Markdown files. rsync --archive --delete --verbose --exclude "*.md" --exclude "*.html" --exclude "feeds" "$SITE_PATH/$SOURCE_DIR/" "$SITE_PATH/$OUTPUT_DIR/" @@ -29,12 +41,21 @@ find "$SITE_PATH/$SOURCE_DIR" -type f -name "*.md" | # Only process files whose destination doesn't exist, or which has been recently changed. if [ ! -f "$NEW_PATH" ] || [[ $(find "$file" -mtime -7) ]]; then echo "$file" + # Get everything after the metadata. - sed "1,/^$/d" "$file" | + if grep -q "^Title: " "$file"; then + HEADERS=$(sed "/^$/q" "$file") + MARKDOWN=$(sed "1,/^$/d" "$file") + else + HEADERS="" + MARKDOWN=$(cat "$file") + fi + + echo "$MARKDOWN" | # Convert Markdown to HTML. markdown | # Recombine with the metadata and hand it to Prolog. - (sed "/^$/q" "$file" && cat) | + combine_headers "$HEADERS" | #gprolog --consult-file parse_entry.pl --consult-file "$SITE_PATH/site.pl" --entry-goal "generate_entry" | swipl --traditional --quiet -l parse_entry.pl -g "consult('$SITE_PATH/site.pl'), generate_entry." | # Some Prolog variants will output banners and "compiling" output no matter how nicely you ask them not to.