diff options
author | EuAndreh <eu@euandre.org> | 2020-10-23 06:40:12 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2020-10-23 06:40:12 -0300 |
commit | da68ac2ae2457196360df43fcc4943db672a193b (patch) | |
tree | 22e396d8320218ef12b1b12588fa1ab37b449de6 /scripts | |
parent | assert-content.sh: Include page title when checking for unique refs (diff) | |
download | euandre.org-da68ac2ae2457196360df43fcc4943db672a193b.tar.gz euandre.org-da68ac2ae2457196360df43fcc4943db672a193b.tar.xz |
assert-content.sh: Enforce filename to be title slug + date
Diffstat (limited to '')
-rwxr-xr-x | scripts/assert-content.sh | 9 |
1 files changed, 7 insertions, 2 deletions
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 } |