-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_post.sh
More file actions
executable file
·83 lines (62 loc) · 1.77 KB
/
create_post.sh
File metadata and controls
executable file
·83 lines (62 loc) · 1.77 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
#!/bin/bash
#
# Time-stamp: <Friday 2024-03-10 21:29:02 Jess Moore>
#
# Create a jekyll website blog post markdown file
# with some template text
#
# Usage: bash create_post.sh install-openhab "How to install OpenHAB"
function usage() {
echo "Usage: $(basename "$0") 'title' 'attendee1, attendee2' 'place'"
echo ""
echo "Description: This script creates a Jekyl post file"
echo " in markdown format with fields: filepart "
echo " and title. Posts are not published until "
echo " post YAML is changed to 'published: true'"
echo " and content built and pushed to web server."
echo ""
echo "Arguments:"
echo " title: Blog post title."
echo " filepart: The text component of the filename. "
echo " Used to construct filename with format"
echo " YYYYMMDD-file-part.md."
echo ""
exit 1 # Exit with a non-zero status to indicate an error
}
if [[ $# -eq 0 || $* == *"help"* || $* == *"-h"* ]]; then
usage
fi
# Datetime of now in jekyll blog post format
NOW=$(date "+%Y-%m-%d %H:%M:%S %z")
# Abbreviated title
FILEPARTNAME=$1
# Blog post title
TITLE=$2
# Date for post filename
NOW_DATE_ONLY=$(date "+%Y-%m-%d")
FILENAME=${NOW_DATE_ONLY}-${FILEPARTNAME}.md
cat > "${FILENAME}" << EOF
---
layout: post
title: "${TITLE}"
date: ${NOW}
published: false
toc: true
---
Short 1-2 sentence introduction.
**Summary**
1. [command] - 1 line explanation
2. [command] - 1 line explanation
## Procedure
### Sub heading 1
Text.
See [other post]({% post_url 2021-03-02-how-to-setup-jekyll %}) for how to do xyz.
[command block]
### Sub heading 2
Text.
[command block]
**References**
- [url1]
- [url2]
EOF
echo "Successfully created post ${FILENAME} with template text."