diff options
author | Squibid <me@zacharyscheiman.com> | 2023-10-30 12:47:55 -0400 |
---|---|---|
committer | Squibid <me@zacharyscheiman.com> | 2023-10-30 12:47:55 -0400 |
commit | 1bc1454b9312e4322d486437055408d1ff35fb22 (patch) | |
tree | 98b270badb82304f520414c35ac8d6b25d7ea466 /blog/newblog | |
parent | 2d90cc615120fcc892c1b22a2d00578b1c486c72 (diff) | |
download | site-1bc1454b9312e4322d486437055408d1ff35fb22.tar.gz site-1bc1454b9312e4322d486437055408d1ff35fb22.tar.bz2 site-1bc1454b9312e4322d486437055408d1ff35fb22.zip |
New blog entry and changes to how blogs are displayed
- blogs are now in subdirs
- blog list is generated through helper function
- full blog list is in blog subdir
Diffstat (limited to '')
-rwxr-xr-x | blog/newblog | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/blog/newblog b/blog/newblog index ea69701..4ab27ba 100755 --- a/blog/newblog +++ b/blog/newblog @@ -1,23 +1,29 @@ #!/bin/sh # generate a base blog file -read -p "Enter name of blog: " name -filename="$(echo $name | sed 's/ /-/g').html" +printf "Enter name of blog entry: " +read -r name +filename="$(echo "$name" | sed 's/ /-/g')" -# make sure we don't overwrite an existent file -[ -f $filename ] && - printf "File already exists! Please choose a different filename.\n"; exit 1 +# make sure we don't overwrite an existing file +if [ -f "$filename" ]; then + printf "Blog entry already exists! Please choose a different name.\n" + exit 1 +fi -printf '<!DOCTYPE HTML> +mkdir "$filename" +cat > "$filename/index.html" << EOF +<!DOCTYPE HTML> <html lang="en"> - <meta name="date" content="2023/07/15"><title>'$name'</title> + <title>'$name'</title> + <meta name="date" content="$(date "+%Y/%m/%d")"> <link rel="stylesheet" href="/style.css"> <body style="background-color: #161617;"> <p> </p> </body> </html> -' > $filename -$EDITOR $filename +EOF +[ "$EDITOR" ] && $EDITOR "$filename/index.html" || vim "$filename/index.html" echo "Make sure to run sup to add to rss feed!" |