diff options
Diffstat (limited to 'barf')
-rwxr-xr-x | barf | 26 |
1 files changed, 11 insertions, 15 deletions
@@ -18,7 +18,7 @@ set -eu MARKDOWN=lowdown IFS=' ' -# Create tab-separated file with filename, title, creation date, last update +# Create tab separated file with filename, title, creation date, last update index_tsv() { for f in "$1"/*.md do @@ -35,13 +35,13 @@ index_html() { # Intro text $MARKDOWN index.md - echo "<ul class='posts'>" + echo "<ul>" # Posts while read -r f title created; do - link=$(echo "$f" | sed -E 's|.*/(.*).md|posts/\1/|') + link=$(echo "$f" | sed -E 's|.*/(.*).md|\1/|') created=$(echo $(head -3 "$f" | tail -1)) - echo "<li><span>$created</span><a href=\"$link\">$title</a></li>" + echo "<li>$created · <a href=\"$link\">$title</a></li>" done < "$1" | sort -r echo "</ul>" @@ -67,8 +67,9 @@ atom_xml() { EOF while read -r f title created; do + content=$($MARKDOWN "$f" | sed 's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g') - post_link=$(echo "$f" | sed -E 's|posts/(.*).md|posts/\1|') + post_link=$(echo "$f" | sed -E 's|posts/(.*).md|\1|') basic_date=$(echo $(head -3 "$f" | tail -1)) published_date=$(date -d $basic_date -u +%Y-%m-%dT10:%M:%SZ) @@ -106,7 +107,7 @@ EOF while read -r f title created; do content=$($MARKDOWN "$f" | sed 's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g') - post_link=$(echo "$f" | sed -E 's|posts/(.*).md|posts/\1|') + post_link=$(echo "$f" | sed -E 's|posts/(.*).md|\1|') basic_date=$(echo $(head -3 "$f" | tail -1)) published_date=$(date -d "$basic_date" -u +"%a, %d %b %Y %H:%M:%S %z") @@ -128,15 +129,8 @@ EOF write_page() { filename=$1 directory=$(echo $(basename "$filename" .md)) - if echo "$filename" | grep -q "^posts/"; then - # Create a directory under build/posts - $(mkdir -p build/posts/$directory) - target=$(echo "$filename" | sed -r 's|posts/(.*).md|build/posts/\1/index.html|') - else - # Create a directory under build for pages - $(mkdir -p build/$directory) - target=$(echo "$filename" | sed -r 's|pages/(.*).md|build/\1/index.html|') - fi + $(mkdir -p build/$directory) + target=$(echo "$filename" | sed -r 's|\w+/(.*).md|build/\1/index.html|') created=$(echo $(head -3 "$filename" | tail -1)) title=$2 @@ -146,6 +140,8 @@ write_page() { > "$target" && cat footer.html >> "$target" } +rm -rf build && mkdir build + # Blog posts index_tsv posts | sort -rt " " -k 3 > build/posts.tsv index_html build/posts.tsv > build/index.html |