-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost.sh
executable file
·41 lines (31 loc) · 873 Bytes
/
post.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# Check if a name is provided
if [ -z "$1" ]; then
echo "Usage: $0 <name>"
exit 1
fi
# Get the name from the argument, convert to lowercase, and replace spaces with hyphens
name=$(echo "$1" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
# Get the current date in the format YYYY-MM-DD
current_date=$(date +"%Y-%m-%d")
# Create the directory path
directory_path="siteContent/posts/${current_date}-${name}"
# Create the directory
mkdir -p "$directory_path"
# Define the content of the page.mdx file
page_content="---
title: '${1}'
type: post
author: scottyob
date: ${current_date}
categories:
- programming
tags:
- tag
hero: hero.jpg
---
"
# Write the content to page.mdx inside the created directory
echo "$page_content" > "${directory_path}/page.mdx"
# Output success message
echo "Directory and page.mdx created successfully at ${directory_path}"