blob: c64d0d5839493d724b26f2c648a91e7b0b537cbb (
plain)
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
|
#!/bin/bash
#
# Generate new content.
#
# Usage:
# bin/new [post|article] SLUG
#
# Examples:
# # create new post with slug "great-news" and title "Great News"
# bin/new post great-news
#
# # create new article with slug "some-stuff" and title "Some Stuff"
# bin/new article some-stuff
#
# # print help
# bin/new help
#
# set sane error handling
set -eu
# switch on type
if [ "$1" = 'post' ]; then
DATE=$(date +%Y-%m-%d)
exec hugo new --editor $EDITOR posts/"$DATE"-"$2".md
elif [ "$1" = 'project' ]; then
# disabled, use projects.yaml instead
# exec hugo new --editor $EDITOR projects/"$2".md
echo "Error: Populate data/projects.yaml instead."
elif [ "$1" = 'article' ]; then
# create article
exec hugo new --editor $EDITOR articles/"$2".md
elif [ "$1" = 'help' -o "x$1" = 'x' ]; then
# print usage
echo "Usage: $0 [post|article]"
else
echo "unknown type: $1"
fi
|