From da68ac2ae2457196360df43fcc4943db672a193b Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Fri, 23 Oct 2020 06:40:12 -0300 Subject: assert-content.sh: Enforce filename to be title slug + date --- scripts/assert-content.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/assert-content.sh b/scripts/assert-content.sh index b9d97b2..a86733d 100755 --- a/scripts/assert-content.sh +++ b/scripts/assert-content.sh @@ -22,9 +22,9 @@ slugify() { echo "${1}" | \ tr '[:upper:]' '[:lower:]' | \ perl -ne 'tr/\000-\177//cd; - s/[^\w\s-]//g; + s/[^\w\s-.]//g; s/^\s+|\s+$//g; - s/[-\s]+/-/g; + s/[-\s.]+/-/g; print;' } @@ -117,6 +117,11 @@ assert-frontmatter() { red "title slug: '$TITLE_SLUG'" exit 1 fi + DESIRED_FILE="${PREFIX}${DATE}-${TITLE_SLUG}.${EXTENSION}" + if [[ ! -f "$DESIRED_FILE" ]]; then + red "File can't be guessed from date+slug: '$DESIRED_FILE' does not exist" + exit 1 + fi fi fi } -- cgit v1.2.3