-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathpost.sh
executable file
·119 lines (101 loc) · 2.3 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
# Make sure API key loads from .zshrc file
source ~/.zshrc
# Get current date, year, and month
DATE=$(date +"%Y-%m-%d")
YEAR=$(date +"%Y")
MONTH=$(date +"%m")
# Get title from user input
echo "Enter the post title:"
read TITLE
echo "Enter the post slug:"
read SLUG
# Replace spaces with hyphens and convert to lowercase
# SLUG=$(echo "$TITLE" | tr "[:upper:]" "[:lower:]" | sed "s/ /-/g")
# Create year and month directories if they don't exist
mkdir -p _posts/$YEAR/$MONTH
# Create the file with YAML frontmatter
FILENAME=_posts/$YEAR/$MONTH/$DATE-$SLUG.md
cat > $FILENAME <<EOL
---
title: "$TITLE"
permalink: /blog/$SLUG
date: $DATE
categories:
- academics-and-practitioners
- ai
- api-doc
- api-doc-site-updates
- beginners
- biking
- blogging
- book-reviews
- creativity
- dita
- family
- findability
- technical-writing
- innovation
- jekyll
- jobs
- podcasts
- podcasting
- podcast-guest
- quick-reference-guides
- screencasting
- simplifying-complexity
- user-centered-documentation
- video
- visual-communication
- web-design
- wikis
- wordpress
- wtd-podcasts
- writing
keywords:
rebrandly: https://idbwrtng.com/$SLUG
description: ""
# podcast_link:
# podcast_file_size:
# podcast_duration: ""
# podcast_length:
# image: filename.png
# series: "Zen and the Art of Motorcycle Maintenance"
# sidebar: sidebar_zamm
# weight: 1.X
# section: peaceofmind
# path1: smartphones/peaceofmind.html
published: false
# thumb:
---
* TOC
{:toc}
{% include ads.html %}
EOL
# Ask user if they want to create a rebrandly shortlink
echo "Would you like to create a rebrandly shortlink? (y/n)"
read answer
if [ "$answer" = "y" ]; then
# get API key from .zshrc file
REBRANDLY_KEY="${REBRANDLY_API_KEY}"
# make API call to Rebrandly to create shortlink
data=$(printf '
{
"domain": {
"fullName": "idbwrtng.com"
},
"destination": "https://idratherbewriting.com/blog/%s",
"slashtag": "%s",
"title": "%s"
}' "$SLUG" "$SLUG" "$TITLE")
response=$(curl --request POST \
--url https://api.rebrandly.com/v1/links \
--header 'accept: application/json' \
--header "apikey: $REBRANDLY_KEY" \
--header 'content-type: application/json' \
--data "$data"
)
echo "Response:" $response
fi
# Open the file in Visual Studio Code
code $FILENAME