aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgenerate.sh68
-rw-r--r--readme.md5
2 files changed, 73 insertions, 0 deletions
diff --git a/generate.sh b/generate.sh
new file mode 100755
index 0000000..74dd29c
--- /dev/null
+++ b/generate.sh
@@ -0,0 +1,68 @@
1#! /usr/bin/env bash
2
3
4post_title() {
5 # remove extension
6 # snake to title case
7 echo "$1" | sed -E -e "s/\..+$//g" -e "s/_(.)/ \u\1/g" -e "s/^(.)/\u\1/g"
8}
9
10post_wrapper() {
11 # 1 - post id
12 # 2 - post content
13 title="$( post_title $1 )"
14 echo -ne "
15 <div class=\"post\">
16 <div class=\"date\">$3</div>
17 <a href=\"#$1\" class=\"post-link\" onClick=\"showPost('$1')\">$title</a>
18 <div id=\"$1\" class=\"post-text\" style=\"display: none\">
19 $2
20 <a href=\"#$1\" class=\"post-end-link\" onClick=\"showPost('$1')\">↑ Collapse</a>
21 <div class="separator"></div>
22 </div>
23 </div>
24 "
25}
26# meta
27echo "
28<!DOCTYPE html>
29<html lang="en">
30<head>
31<link rel="stylesheet" href="../style.css">
32<meta charset="UTF-8">
33<title>n</title>
34" > ./docs/index.html
35
36# script
37echo '<script>' >> docs/index.html
38for s in ./script/*; do
39 cat "$s" >> docs/index.html
40done
41echo '</script> </head>' >> docs/index.html
42
43# body
44echo "
45<body>
46<div class="black-circle">
47 <h1 class="heading">n</h1>
48</div>
49<div class="posts">
50" >> docs/index.html
51
52# posts
53posts=$(ls -t ./posts);
54for f in $posts; do
55 file="./posts/"$f
56 echo "generating post $file"
57 id="${file##*/}" # ill name my posts just fine
58 html=$(lowdown "$file")
59 post_date=$(date -r "$file" "+%d/%m %Y")
60 post_div=$(post_wrapper "$id" "$html" "$post_date")
61 echo -ne "$post_div" >> docs/index.html
62done
63
64echo "
65</div>
66</body>
67</html>
68" >> docs/index.html
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..53bfdcf
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,5 @@
1# nerdypepper.me
2
3my blog, put together with a very basic static site generator crafted with
4`bash` and `sed`; `lowdown` for markdown to html.
5