diff options
Diffstat (limited to 'generate.sh')
-rwxr-xr-x | generate.sh | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/generate.sh b/generate.sh index af70b33..5399b3a 100755 --- a/generate.sh +++ b/generate.sh | |||
@@ -1,28 +1,23 @@ | |||
1 | #! /usr/bin/env bash | 1 | #! /usr/bin/env bash |
2 | 2 | ||
3 | 3 | ||
4 | post_title() { | 4 | title_wrapper() { |
5 | # remove extension | 5 | # remove extension |
6 | # snake to title case | 6 | # snake to title case |
7 | echo "$1" | sed -E -e "s/\..+$//g" -e "s/_(.)/ \u\1/g" -e "s/^(.)/\u\1/g" | 7 | echo "$1" | sed -E -e "s/\..+$//g" -e "s/_(.)/ \u\1/g" -e "s/^(.)/\u\1/g" |
8 | } | 8 | } |
9 | 9 | ||
10 | post_wrapper() { | 10 | link_wrapper() { |
11 | # 1 - post id | 11 | # 1 - id |
12 | # 2 - post content | 12 | # 2 - title |
13 | # 3 - date | 13 | # 2 - date |
14 | title="$( post_title $1 )" | ||
15 | echo -ne " | 14 | echo -ne " |
16 | <details class=\"post\"> | 15 | <div class=\"post\"> |
17 | <summary> | 16 | <div class=\"date\">$3</div> |
18 | <div class=\"date\">$3</div> | 17 | <a href=\"/posts/$1.html\" class=\"post-link\"> |
19 | <span class=\"post-link\">$title</span> | 18 | <span class=\"post-link\">$2</span> |
20 | </summary> | 19 | </a> |
21 | <div class=\"post-text\"> | 20 | </div> |
22 | $2 | ||
23 | <div class="separator"></div> | ||
24 | </div> | ||
25 | </details> | ||
26 | " | 21 | " |
27 | } | 22 | } |
28 | 23 | ||
@@ -57,17 +52,22 @@ echo " | |||
57 | 52 | ||
58 | # posts | 53 | # posts |
59 | posts=$(ls -t ./posts); | 54 | posts=$(ls -t ./posts); |
55 | mkdir -p docs/posts | ||
56 | |||
60 | for f in $posts; do | 57 | for f in $posts; do |
61 | file="./posts/"$f | 58 | file="./posts/"$f |
62 | echo "generating post $file" | 59 | echo "generating post $file" |
63 | id="${file##*/}" # ill name my posts just fine | 60 | id="${file##*/}" # ill name my posts just fine |
64 | 61 | ||
65 | html=$(lowdown "$file") | ||
66 | 62 | ||
67 | # generate posts | 63 | # generate posts |
64 | html=$(lowdown "$file") | ||
65 | post_title=$(title_wrapper "$id") | ||
68 | post_date=$(date -r "$file" "+%d/%m %Y") | 66 | post_date=$(date -r "$file" "+%d/%m %Y") |
69 | post_div=$(post_wrapper "$id" "$html" "$post_date") | 67 | post_link=$(link_wrapper "${id%.*}" "$post_title" "$post_date") |
70 | echo -ne "$post_div" >> docs/index.html | 68 | |
69 | echo -ne "$post_link" >> docs/index.html | ||
70 | esh -s /bin/bash -o "docs/posts/${id%.*}.html" "./post.esh" file="$file" date="$post_date" title="$post_title" | ||
71 | first_visible="0" | 71 | first_visible="0" |
72 | done | 72 | done |
73 | 73 | ||