-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathpost.sh
More file actions
executable file
·121 lines (104 loc) · 2.57 KB
/
post.sh
File metadata and controls
executable file
·121 lines (104 loc) · 2.57 KB
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
120
121
#!/bin/bash
# Try loading REBRANDLY_API_KEY from common zsh config files
# Handles variations like: export KEY=value, export KEY="value", KEY=value
for rc_file in ~/.zshenv ~/.zshrc ~/.zprofile; do
if [[ -f "$rc_file" ]]; then
eval "$(grep -E '^\s*(export\s+)?REBRANDLY_API_KEY\s*=' "$rc_file" 2>/dev/null | sed 's/^\s*export\s*//' | sed 's/^/export /')"
fi
done
# 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
# 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
- ai-book-club
- 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
# image:
---
* 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
REBRANDLY_KEY="${REBRANDLY_API_KEY}"
# Validate the key was actually loaded
if [[ -z "$REBRANDLY_KEY" ]]; then
echo "Error: REBRANDLY_API_KEY not found. Check that it's defined in ~/.zshrc or ~/.zshenv."
exit 1
fi
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 -a Antigravity "$FILENAME"