summaryrefslogtreecommitdiff
path: root/build.sh
blob: c0aedbddd0d38885742f0c51c1853a671703ee09 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh

header='<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
  body {
	  max-width: 45rem;
	  margin: auto;
	  padding: 0.5em;
	  text-align: justify;
  }
  h1 { text-align: center }
  pre {
    border: 1px solid;
	padding: 1ch;
	border-radius: 5px;
	overflow: auto;
	background-color: #eee;
  }
</style>
'

genhtml() (
	cd "$1"

    . ./meta.sh

	exec 1>index.html

	# Header
	echo "<!DOCTYPE html>"
	echo "<title>$title</title>"
	echo "<!-- generated by build.sh. DO NOT EDIT. -->"
	echo "$header"
	[ "$1" != . ] && echo "<a href=\"..\">$blog_title</a><hr>"

	# Body
	pandoc *.md

	# Footer
	[ "$1" != . ] && echo "<hr>From: $author, $date"
)

for d in *; do
	[ -d "$d" ] && genhtml "$d"
done
genhtml .

# Fix for mastodon.
sed '/mstdn/s/href=/rel="me" href=/' index.html >xx && mv xx index.html
# Put a license in index footer.
echo '<hr><small>Unless otherwise noted, posts are licensed under 
<a href="http://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a>.</small>' >>index.html