From 1b7802f36afa8fb12cce94a8a48ea966d4aa352f Mon Sep 17 00:00:00 2001 From: clement Date: Mon, 8 Jun 2020 19:24:33 +0800 Subject: [PATCH] Fixed broken indexing --- scripts/build-website.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/build-website.sh b/scripts/build-website.sh index fb5faf7..1c7d072 100755 --- a/scripts/build-website.sh +++ b/scripts/build-website.sh @@ -4,7 +4,7 @@ # build the blog files cd ../blog -CONTENTNUM=$(ls content-* | wc -l ) +CONTENTNUM=$(($(ls content-* | wc -l)-1)) for ((i=-1;i<$CONTENTNUM;i++)) do padint="$(printf %03d $i)" @@ -14,10 +14,10 @@ do blogname="blog-$padint" # interactive tail - if [[ $i >= 0 ]];then + if (( $i >= 0 )) ;then cp filetail "$tailname" padintprev="$(printf %03d $(($i - 1)) )" - if [[ $(($i+1)) == $CONTENTNUM ]];then + if (( $(($i+1)) == $CONTENTNUM )) ;then padintnext="$(printf %03d -1 )" else padintnext="$(printf %03d $(($i + 1)) )" @@ -27,13 +27,15 @@ do fi # cat together - cat filehead "$contentname" "$tailname" "$quotename" > "$blogname" + if [[ -f $contentname ]] ;then + cat filehead "$contentname" "$tailname" "$quotename" > "$blogname" + fi done # clean up non prod files cd ../blog -#rm filehead filetail content* quote* .blog.* tail* +rm filehead filetail content* quote* .blog.* tail* cd ../ -#rm -rf .git scripts .index.html.* README.md +rm -rf .git scripts .index.html.* README.md find . -type f | xargs chmod 600 find . -type d | xargs chmod 700