blob: 5399b3a3f1b1ca90d19d90161c6d4b804f8eb9ce (
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
|
#! /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"
}
link_wrapper() {
# 1 - id
# 2 - title
# 2 - date
echo -ne "
<div class=\"post\">
<div class=\"date\">$3</div>
<a href=\"/posts/$1.html\" class=\"post-link\">
<span class=\"post-link\">$2</span>
</a>
</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>
" >> docs/index.html
# begin posts
echo "
<div class=\"posts\">
" >> 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")
post_title=$(title_wrapper "$id")
post_date=$(date -r "$file" "+%d/%m %Y")
post_link=$(link_wrapper "${id%.*}" "$post_title" "$post_date")
echo -ne "$post_link" >> docs/index.html
esh -s /bin/bash -o "docs/posts/${id%.*}.html" "./post.esh" file="$file" date="$post_date" title="$post_title"
first_visible="0"
done
echo "
</div>
</body>
</html>
" >> docs/index.html
|