blob: 7bbe3c1a688e78d09df0580215481e29730f39b1 (
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
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
|
#! /usr/bin/env bash
title_wrapper() {
# remove extension
# snake to title case
echo "$1" | sed -E -e "s/\..+$//g" -e "s/_(.)/ \u\1/g" -e "s/^(.)/\u\1/g"
}
read_time() {
minu="$(eva -f 1 $1/150 | xargs)"
echo "$minu"
}
height() {
cm="$(eva -f 2 $1*18*0.0222 | xargs)"
echo "$cm"
}
link_wrapper() {
# 1 - id
# 2 - title
# 3 - date
# 4 - read time
echo -ne "
<div class=\"post\">
<div class=\"date\">
$3
</div>
<a href=\"/posts/$1\" class=\"post-link\">
<span class=\"post-link\">$2</span>
</a>
<div class="stats">
<span class=\"stats-number\">
$4
</span>
<span class="stats-unit">min</span>
</div>
</div>
"
}
# meta
echo "
<!DOCTYPE html>
<html lang=\"en\">
<head>
<link rel=\"stylesheet\" href=\"./style.css\">
<meta charset=\"UTF-8\">
<meta name=\"viewport\" content=\"initial-scale=1\">
<meta content=\"#ffffff\" name=\"theme-color\">
<meta name=\"HandheldFriendly\" content=\"true\">
<meta property=\"og:title\" content=\"nerdypepper\">
<meta property=\"og:type\" content=\"website\">
<meta property=\"og:description\" content=\"a static site {for, by, about} me \">
<meta property=\"og:url\" content=\"https://nerdypepper.tech\">
<title>n</title>
" > ./docs/index.html
# body
echo "
<body>
<h1 class=\"heading\">n</h1>
<h4 class=\"date\">nerdypepper's μblog</h4>
" >> docs/index.html
# begin posts
echo "
<div class=\"posts\">
<div class="separator"></div>
" >> docs/index.html
# posts
posts=$(ls -t ./posts);
mkdir -p docs/posts
for f in $posts; do
file="./posts/"$f
echo "generating post $file"
id="${file##*/}" # ill name my posts just fine
# generate posts
html=$(lowdown "$file")
stats=$(wc "$file")
words="$(echo $stats | awk '{print $2}')"
lines="$(echo $stats | awk '{print $1}')"
r_time="$(read_time $words)"
height="$(height $lines)"
post_title=$(title_wrapper "$id")
post_date=$(date -r "$file" "+%d/%m %Y")
post_link=$(link_wrapper "${id%.*}" "$post_title" "$post_date" "$r_time" "$height")
echo -ne "$post_link" >> docs/index.html
id="${id%.*}"
mkdir -p "docs/posts/$id"
esh -s /bin/bash \
-o "docs/posts/$id/index.html" \
"./post.esh" \
file="$file" \
date="$post_date" \
title="$post_title" \
read_time="$r_time" \
height="$height"
done
echo "
<div class="separator"></div>
<div class="footer">
<a href="https://github.com/nerdypepper">Github</a>
·
<a href="https://twitter.com/N3rdyP3pp3r">Twitter</a>
·
<a href="mailto:[email protected]">Mail</a>
·
<a href="https://linkedin.com/in/nerdypepper">LinkedIn</a>
</div>
</div>
</body>
</html>
" >> docs/index.html
|