fakestache-ssg

[Archived] A static site generator in Bash 4.
Log | Files | Refs | Submodules | README

commit 0c7e05b180adf6e481e195066b45af5feb6fb146
parent 43b65b2ae1fa708e2df8bef2a9d8c353f7b651b7
Author: Hugo Soucy <hugo.soucy@savoirfairelinux.com>
Date:   Tue,  1 Nov 2016 17:29:46 -0400

Remove all the special chars with regex.

Diffstat:
Mfakestache | 13++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/fakestache b/fakestache @@ -38,15 +38,14 @@ case $1 in archetype_datetime=$NOW_DATETIME archetype_template="$1" - remove_whitespace=${archetype_title// /-} - remove_quote=${remove_whitespace//\'/-} - remove_capitalletter=${remove_quote,,} + # Remove special chars for the filename + archetype_title_nospecials=${archetype_title//[^A-Za-z0-9]/-} + archetype_filename=${archetype_title_nospecials//--/}.md - archetype_filename=${remove_capitalletter}.md + mo $ARCHETYPES_PATH/$1.md > $CONTENT_PATH/$1/"${NOW_DATE:0:4}"/"${NOW_DATE:5:2}"/"${archetype_filename,,}" - mo $ARCHETYPES_PATH/$1.md > $CONTENT_PATH/$1/"${NOW_DATE:0:4}"/"${NOW_DATE:5:2}"/"$archetype_filename" - - echo "- The file '$CONTENT_PATH/$1/${NOW_DATE:0:4}/${NOW_DATE:5:2}/$archetype_filename' hab been created." + echo "- The file '$CONTENT_PATH/$1/${NOW_DATE:0:4}/${NOW_DATE:5:2}/${archetype_filename,,}' hab been created." + exit 0 else echo "- ERROR: Requires a second argument! You need a title to create a $1." >&2