added shell script for new post

This commit is contained in:
andwati
2025-05-08 17:22:08 +03:00
parent afdad5f9a8
commit 8cb2975d93
2 changed files with 35 additions and 0 deletions
@@ -0,0 +1,6 @@
---
title: "Bitsiege Ctf Writeup"
description: ""
date: 2025-05-08 +0300
tags: []
---
+29
View File
@@ -0,0 +1,29 @@
#!/bin/bash
# Check if a title argument was passed
if [ -z "$1" ]; then
echo "Usage: $0 <slugified-title>"
exit 1
fi
# Get the current date
DATE=$(date +"%Y-%m-%d")
TIMEZONE="+0300"
TITLE_SLUG="$1"
FILENAME="${DATE}-${TITLE_SLUG}.md"
POST_PATH="_posts/${FILENAME}"
# Convert slugified title to a proper title
TITLE=$(echo "$TITLE_SLUG" | sed 's/-/ /g' | sed -E 's/\b(.)/\U\1/g')
# Create the post file with frontmatter
cat <<EOF > "$POST_PATH"
---
title: "${TITLE}"
description: ""
date: ${DATE} ${TIMEZONE}
tags: []
---
EOF
echo "New post created at $POST_PATH"