From 7135f165e0dd829155171461098444bbe538cd7e Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Fri, 22 May 2020 23:36:27 +0100 Subject: [PATCH] A few changes to my build script --- build.sh | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/build.sh b/build.sh index 7c055f7..653d713 100755 --- a/build.sh +++ b/build.sh @@ -23,7 +23,7 @@ makeIntro(){ # We delete tmp each time the build script runs, so if the file exists, we have already generated one this time [ -f "$output" ] && return 1 mkdir -p "${output%/*}" - local info="$(sed -n '/---/,/---/p' "$file" | sed '/^$/,$d' | sed '/^---$/d')" + local info="$(sed -n '/---/,/---/p' "$file" | sed '/^$/,$d' | sed -n '1,/---/p' | sed '/^---$/d')" local slug=$(getBlogSlug "$file") local date="$(echo "$info" | yq -r .date)" local tags="$(echo "$info" | yq -r 'if ( .tags | type ) == "array" then .tags else [ .tags ] end | join("\n")' | awk '{print "
  • " $0 "
  • "}' )" @@ -54,7 +54,7 @@ index(){ local template="$(echo "" | pandoc --template=templates/blog.html -f markdown -t html5 -M frontpage 2> /dev/null )" # First loop makes all the intros needed and stores them in tmp/intros - find content/blog/ -type f -name '*.md' | sort -r | head -n 10 | while read file; do + find content/blog/ -type f -name '*.md' | grep -v 'xxx' | sort -r | head -n 20 | while read file; do makeIntro "$file" & done wait @@ -62,7 +62,7 @@ index(){ # Once they are created, we will put them in, in order ( echo "$template" | sed -n '1,/#CONTENT#/p' | head -n -1 - find content/blog/ -type f -name '*.md' | sort -r | head -n 10 | while read file; do + find content/blog/ -type f -name '*.md' | grep -v 'xxx' | sort -r | head -n 20 | while read file; do grep -Eq '^draft: true' "$file" || getIntro "$file" done echo "$template" | sed -n '/#CONTENT#/,$p' | sed '1d' @@ -76,7 +76,7 @@ tagIndex(){ [ ! -f "tmp/templates/tagList.html" ] && echo "No taglist file" | tee "tmp/templates/tagList.html" > /dev/stderr local template="$(echo "" | pandoc --template=templates/blog.html -f markdown -t html5 -M archive -M title:"$title Archive" 2> /dev/null )" - cat "$1" | sort -r | while read file; do + cat "$1" | grep -v 'xxx' | sort -r | while read file; do makeIntro "$file" & done wait @@ -94,7 +94,7 @@ html_tag_list(){ echo "" @@ -110,8 +110,9 @@ tags(){ # Loops through each blog and puts it in tag lists, although only blogs that have changed local newer="" [ -f tmp/lastTagUpdate ] && newer="-newer tmp/lastTagUpdate" - find content/blog/ -type f -name '*.md' $newer | while read file; do - sed -n '/---/,/---/p' "$file" | sed '/^---$/d' | sed '/^$/,$d' | yq -r 'if ( .tags | type ) == "array" then .tags else [ .tags ] end | join("\n")' | while read tag; do + find content/blog/ -type f -name '*.md' -not -name 'xxx-*' $newer | while read file; do + sed -n '/---/,/---/p' "$file" | sed -n '1,/---/p' | sed '/^---$/d' | sed '/^$/,$d' | yq -r 'if ( .tags | type ) == "array" then .tags else [ .tags ] end | join("\n")' | while read tag; do + tag=$(echo "$tag" | tr ' ' '_') # Adds the file to the tags list if it's not already in there grep -q "$file" tmp/tag/"$tag" 2> /dev/null || echo "$file" >> tmp/tag/"$tag" done @@ -131,6 +132,11 @@ tags(){ touch tmp/lastTagUpdate } +card(){ + echo "Generating Card" + content/card.curl > public_html/card +} + clean(){ rm -rf tmp > /dev/null 2> /dev/null @@ -149,5 +155,6 @@ case "$1" in index) index ;; blog) blog ;; tags) tags ;; - all) tags && blog && index ;; + card) card ;; + all) tags && blog && index && card ;; esac