From 23463494c2eeeb20ac162909b520b6828ae7acc8 Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Tue, 30 Jul 2019 14:13:27 +0530 Subject: init --- generate.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ readme.md | 5 +++++ 2 files changed, 73 insertions(+) create mode 100755 generate.sh create mode 100644 readme.md diff --git a/generate.sh b/generate.sh new file mode 100755 index 0000000..74dd29c --- /dev/null +++ b/generate.sh @@ -0,0 +1,68 @@ +#! /usr/bin/env bash + + +post_title() { + # remove extension + # snake to title case + echo "$1" | sed -E -e "s/\..+$//g" -e "s/_(.)/ \u\1/g" -e "s/^(.)/\u\1/g" +} + +post_wrapper() { + # 1 - post id + # 2 - post content + title="$( post_title $1 )" + echo -ne " +
+
$3
+ $title +
+ $2 + ↑ Collapse +
+
+
+ " +} +# meta +echo " + + + + + +n +" > ./docs/index.html + +# script +echo ' ' >> docs/index.html + +# body +echo " + +
+

n

+
+
+" >> docs/index.html + +# posts +posts=$(ls -t ./posts); +for f in $posts; do + file="./posts/"$f + echo "generating post $file" + id="${file##*/}" # ill name my posts just fine + html=$(lowdown "$file") + post_date=$(date -r "$file" "+%d/%m %Y") + post_div=$(post_wrapper "$id" "$html" "$post_date") + echo -ne "$post_div" >> docs/index.html +done + +echo " +
+ + +" >> 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 @@ +# nerdypepper.me + +my blog, put together with a very basic static site generator crafted with +`bash` and `sed`; `lowdown` for markdown to html. + -- cgit v1.2.3