Use previous blog post index when deleting

This commit is contained in:
Bob Mottram 2016-09-09 09:18:16 +01:00
parent 74437ea53a
commit f15a234346
No known key found for this signature in database
GPG Key ID: 0452CC7CEA982E38
1 changed files with 5 additions and 2 deletions

View File

@ -105,7 +105,8 @@ function delete_blog {
return
fi
CURRENT_INDEX=$(cat $CURRENT_BLOG_INDEX)
LAST_BLOG_ENTRY=$BLOG_CONTENT_PATH/${CURRENT_INDEX}_post.rst
PREVIOUS_INDEX=$((CURRENT_INDEX - 1))
LAST_BLOG_ENTRY=$BLOG_CONTENT_PATH/${PREVIOUS_INDEX}_post.rst
if [ ! -f $LAST_BLOG_ENTRY ]; then
return
fi
@ -118,8 +119,10 @@ function delete_blog {
case $sel in
0) rm $LAST_BLOG_ENTRY
if [ $CURRENT_INDEX -gt 0 ]; then
CURRENT_INDEX=$((CURRENT_INDEX - 1))
CURRENT_INDEX=$PREVIOUS_INDEX
echo "$CURRENT_INDEX" > $CURRENT_BLOG_INDEX
else
rm -f $CURRENT_BLOG_INDEX
fi
regenerate_blog
;;