new_post.sh: fix issue on subsequent runs

Closes #1
This commit is contained in:
Evilham 2024-05-08 22:53:37 +02:00
parent 03d4ec8f78
commit 6916851eec
Signed by: evilham
GPG key ID: AE3EE30D970886BF

View file

@ -9,9 +9,9 @@ if [ -z "${path_to_rendered_md}" ] || [ ! -f "${path_to_rendered_md}" ]; then
fi
# Get the number for the new issue
publications="$(find posts/ -maxdepth 1 -mindepth 1 -type d)"
last_date="$(echo "${publications}" | tail -n 1 | cut -d '/' -f 2)"
today="$(date +"%Y-%m-%d")"
publications="$(find posts/ -maxdepth 1 -mindepth 1 -type d | sort | grep -v "${today}")"
last_date="$(echo "${publications}" | tail -n 1 | cut -d '/' -f 2)"
current_number="$(echo "${publications}" | grep -v "${today}" | wc -l)"
next_number="$(($current_number+1))"