1# Build everything then deploy
2default: site (docs "pdf") (docs "epub") (docs "txt") images deploy
3
4# Deploy website
5deploy:
6 # Deploying website ...
7 rsync -qavmzz public/ hel1:/var/www/secluded/
8 # Website deployed
9
10# Build website
11site:
12 # Building website ...
13 hugo --quiet
14
15# Build documents of filetype ext
16docs ext:
17 #!/usr/bin/env bash
18
19 echo -e '\033[1m# Checking whether there are new {{uppercase(ext)}}s to generate ...\033[0m'
20
21 export WEBROOT=public
22
23 published=$(grep -ilr --include \*.md "draft: false" content)
24
25 todo=""
26
27 # Iterate through all non-drafts
28 for path in $published
29 do
30 filename=$(basename "$path")
31 name=$(echo "${filename%.*}")
32 # Check whether target doc is newer than Markdown file
33 if [ "$path" -nt "public/$name/$name.{{ext}}" ]
34 then
35 todo+="$path "
36 fi
37 done
38
39 if [ -z "$todo" ]
40 then
41 echo "No {{uppercase(ext)}}s to generate"
42 exit 0
43 else
44 for path in $todo
45 do
46 filename=$(basename "$path")
47 name=$(echo "${filename%.*}")
48 echo "Generating $name.{{ext}}"
49
50 if [ "{{ext}}" == "pdf" ]
51 then
52 pandoc --quiet -f markdown -t pdf --lua-filter=pandoc_config/images.lua --pdf-engine=xelatex -V 'linkcolor:blue' --listings -H pandoc_config/styles.tex $path -o public/$name/$name.pdf
53 elif [ "{{ext}}" == "epub" ]
54 then
55 pandoc --quiet -f markdown -t epub3 --lua-filter=pandoc_config/images.lua --pdf-engine=xelatex -V 'linkcolor:blue' --listings -H pandoc_config/styles.tex $path -o public/$name/$name.epub
56 elif [ "{{ext}}" == "txt" ]
57 then
58 pandoc --quiet -f markdown -t plain --lua-filter=pandoc_config/images.lua $path -o public/$name/$name.txt
59 fi
60 done
61 fi
62
63# Generate cover images
64images:
65 #!/usr/bin/env bash
66
67 echo -e '\033[1m# Checking whether there are cover images to generate ...\033[0m'
68
69 published=$(grep -ilr --include \*.md "draft: false" content)
70
71 todo=""
72
73 # Iterate through all non-drafts
74 for path in $published
75 do
76 filename=$(basename "$path")
77 name=$(echo "${filename%.*}")
78 # Check whether target doc is newer than Markdown file
79 if [ "$path" -nt "public/$name/cover.png" ]
80 then
81 todo+="$path "
82 fi
83 done
84
85 if [ "content/_index.md" -nt "public/cover.png" ]
86 then
87 p2c -o public/cover.png -t "A Secluded Home" -s "Personal corner of the web for a musician, developer, sysadmin, podcaster, and small business owner"
88 fi
89
90 if [ -z "$todo" ]
91 then
92 echo "No covers to generate"
93 exit 0
94 else
95 for path in $todo
96 do
97 filename=$(basename "$path")
98 name=$(echo "${filename%.*}")
99 echo "Generating cover for $name"
100
101 p2c -i $path -o public/$name/cover.png
102 done
103 fi
104
105# Generate feeds post from OPML file in /tmp/subscriptions.opml
106opml:
107 go install git.sr.ht/~amolith/opml2md@latest
108 opml2md -i /tmp/subscriptions.opml -o content/feeds.md -x static/feeds.opml -t opml.tmpl -g "Software updates,Newsletters"
109
110# Run development server
111serve:
112 hugo server
113
114# Run development server
115served:
116 hugo server -D