-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTaskfile.yml
More file actions
163 lines (146 loc) · 4.12 KB
/
Taskfile.yml
File metadata and controls
163 lines (146 loc) · 4.12 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
version: '3'
dotenv: ['.env']
vars:
TERMUX: '{{and .PREFIX (contains "com.termux" .PREFIX)}}'
TODAY: '{{now | date "2006-01-02"}}'
HUGO: '{{default "hugo" .HUGO}}'
tasks:
serve:
desc: Runs hugo serve, all posts visible.
cmds:
- |
{{.HUGO}} serve -D -E -F {{if .TERMUX}}--noBuildLock{{end}} --bind=127.0.0.1 --baseURL=http://127.0.0.1:1313
clean:
desc: Clean the page build folder.
cmds:
- |
rm -r ./public || true
build:
desc: Create a production build of the site in ./public.
deps:
- clean
cmds:
- |
{{.HUGO}} --minify {{if .TERMUX}}--noBuildLock{{end}}
validate:
desc: Validates the page build.
deps:
- build
cmds:
- |
bash validate.sh
new-blog:
desc: Creates a new blog post.
vars:
TITLE: '{{.CLI_ARGS}}'
SLUG: '{{trimall "-" (regexReplaceAll "--+" (regexReplaceAll "[^A-Za-z0-9-]" (regexReplaceAll "\\s+" (lower .TITLE) "-") "") "-")}}'
DIR: 'content/blog/{{.TODAY}}-{{.SLUG}}'
FILE: '{{.DIR}}/index.md'
preconditions:
- sh: '[ ! -d "{{.DIR}}" ]'
cmds:
- |
mkdir "{{.DIR}}"
cat > "{{.FILE}}" <<EOF
---
title: "{{.TITLE}}"
#description:
date: {{.TODAY}}
cover:
image: cover.jpg
alt: Add cover.jpg at ~1200x600px and describe it here
relative: true
draft: true
---
EOF
echo "{{.FILE}}"
new-til:
desc: Creates a new TIL post.
vars:
TITLE: '{{.CLI_ARGS}}'
SLUG: '{{trimall "-" (regexReplaceAll "--+" (regexReplaceAll "[^A-Za-z0-9-]" (regexReplaceAll "\\s+" (lower .TITLE) "-") "") "-")}}'
FILE: 'content/til/{{.SLUG}}.md'
preconditions:
- sh: '[ ! -f "{{.FILE}}" ]'
cmds:
- |
cat > {{.FILE}} <<EOF
---
title: "{{.TITLE}}"
date: {{.TODAY}}
tags: []
draft: true
---
EOF
echo {{.FILE}}
to-bundle:
desc: Turns a single page (page.md) into a bundle (page/index.md).
vars:
PAGE: 'content/{{trimPrefix "content/" .CLI_ARGS}}'
DIR: '{{trimSuffix ".md" .PAGE}}'
preconditions:
- test -f "{{.PAGE}}"
- sh: "[ ! -d \"{{.DIR}}\" ]"
cmds:
- |
mkdir "{{.DIR}}"
mv "{{.PAGE}}" "{{.DIR}}/index.md"
to-single:
desc: Turns a bundle (page/index.md) into a single page (page.md).
vars:
BUNDLE: 'content/{{trimPrefix "content/" (trimSuffix "/" .CLI_ARGS)}}'
PAGE: '{{.BUNDLE}}.md'
preconditions:
- test -d "{{.BUNDLE}}"
- test -f "{{.BUNDLE}}/index.md"
- sh: "[ ! -f \"{{.BUNDLE}}.md\" ]"
- sh: "[ -n $(find \"{{.BUNDLE}}\" -mindepth 1 -maxdepth 1 | grep -v index.md) ]"
cmds:
- |
mv "{{.BUNDLE}}/index.md" "{{.PAGE}}"
rm -r "{{.BUNDLE}}"
redate:
desc: Redates a page to today's date.
vars:
PATH: 'content/{{trimPrefix "content/" (trimSuffix "/" .CLI_ARGS)}}'
cmds:
- |
if [ -d "{{.PATH}}" ]; then
# bundle
file="{{.PATH}}/index.md"
path="{{.PATH}}"
elif [ -f "{{.PATH}}.md" ]; then
# page
file="{{.PATH}}.md"
path="$file"
fi
current=$(yq -f extract '.date | format_datetime("2006-01-02")' $file)
echo $current
yq -i -f process '.date=now' $file
now=$(yq -f extract '.date | format_datetime("2006-01-02")' $file)
echo $now
rename="${path//$current/$now}"
echo $rename
mv "$path" "$rename" || true
add-vouch:
desc: Adds a new vouch to human.json.
vars:
PAGE: '{{.CLI_ARGS}}'
FILE: 'data/vouches.yaml'
cmds:
- |
cat >> {{.FILE}} <<EOF
- url: {{.PAGE}}
date: "{{.TODAY}}"
EOF
echo {{.FILE}}
update-mods:
desc: Updates all submodules.
cmds:
- git submodule update --remote --merge
- cd themes/PaperMod && git pull origin master
- cd themes/hugo-notice && git pull origin main
fetch-toots:
desc: Updates data of all toot shortcodes.
cmds:
- bash fetch-toots.sh