diff --git a/Makefile b/Makefile index e94b1f0..e8c0885 100644 --- a/Makefile +++ b/Makefile @@ -5,3 +5,6 @@ compile: w: $(GS) -w config + +new: + sh scripts/new.sh diff --git a/scripts/new.sh b/scripts/new.sh new file mode 100644 index 0000000..010c06e --- /dev/null +++ b/scripts/new.sh @@ -0,0 +1,32 @@ +#! /bin/sh + +title="" +author="" +tags="" +folder_name="" +# Get current date +date=$(date +%Y-%m-%d) + +read -p "Enter new blog title: " title +read -p "Enter author's name: " author +read -p "Enter tags (seperated by spaces): " tags + +# Replace spaces with dashes for tags +tags=$(echo $tags | sed -e 's/ /,/g') + +# Convert to lowercase, trim non-alpha characters and replace spaces with dashes for folder name +folder_name=$(echo $title | tr '[:upper:]' '[:lower:]' | sed -e 's/ /-/g' | sed -e 's/[,.!]//g') + +folder_path="src/blog/$folder_name" + +# Create folder +mkdir -p $folder_path +# Flush metadata to the new blog file +printf "title: $title +author: $author +date: $date +tags: $tags +---- +" >> $folder_path/index.md + +echo "New blog created at $folder_path" diff --git a/src/blog/hello-world/index.md b/src/blog/hello-world/index.md new file mode 100644 index 0000000..b6fdc22 --- /dev/null +++ b/src/blog/hello-world/index.md @@ -0,0 +1,6 @@ + +title: Hello, World! +author: VnPower +date: 2022-08-09 +tags: hello,testing +---- diff --git a/src/blog/new/index.md b/src/blog/new/index.md deleted file mode 100644 index b7bd546..0000000 --- a/src/blog/new/index.md +++ /dev/null @@ -1,8 +0,0 @@ -title: New blog -author: VnPower -date: 2022-08-09 -tags:hello ----- - -# OMG! -Hello! diff --git a/src/blog/test/index.md b/src/blog/test/index.md deleted file mode 100644 index 321058d..0000000 --- a/src/blog/test/index.md +++ /dev/null @@ -1,17 +0,0 @@ -title: Test -author: VnPower -date: 2022-07-09 -tags: code, rust ----- - -# Hi? Overflow testing - -asd - -```rust -fn greet() { - println!("Hi there!"); -} - -let x = 69; -```