-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_blog_post
executable file
·56 lines (44 loc) · 1.51 KB
/
create_blog_post
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
#! /bin/bash
if [ -z "$1" ]; then
echo "Error: Missing argument"
echo
echo "Usage:"
echo " $0 <short-title>"
echo
echo "Example:"
echo " $0 \"New blog post\""
exit 1
fi
# convert the title to a file name
title=$(echo -n "$1" | tr "[:upper:]" "[:lower:]" | tr "[:space:]" "-" | tr -d -c "[:alnum:]-" )
# current date in YYYY-MM-DD format
date=$(date +%F)
# blog post MDX file
mdx="blog/${date}-${title}.mdx"
# directory for storing images
img="static/img/blog/$date"
cat <<EOF > "$mdx"
---
title: $1
discussion_id: 42 # ID from https://github.com/agama-project/agama-project.github.io/discussions/<ID>
tags:
- release
---
This is a template for Agama blog posts. All text above the "truncate" comment is displayed also in
the blog index page as a summary.
{/* truncate */}
## Heading {#heading}
Place images into the \`static/img/blog/$date\` directory and insert them with this Markdown:
![Image description](../static/img/blog/$date/image.png)
See the blog.md file for more details about writing blog posts.
EOF
echo "Created blog post: $mdx"
mkdir -p "$img"
echo "Image directory: $img"
discussion_date=$(echo -n "$date" | tr - /)
# use the same naming schema for manually created discussion as for the
# discussions automatically created by Giscus
echo
echo "Create a discussion with \"blog/$discussion_date/$title\" title at"
echo "https://github.com/agama-project/agama-project.github.io/discussions/new?category=blog"
echo "and set the new ID in the \"discussion_id\" value in the blog front matter"