From 3414053d7cd17b43dd929e4e5fc468d98145e0d5 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 17 Oct 2020 12:34:30 +0530 Subject: update intro, new post: Self-hosting Git! --- docs/posts/static_sites_with_bash/index.html | 41 +++++++++++++++------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'docs/posts/static_sites_with_bash/index.html') diff --git a/docs/posts/static_sites_with_bash/index.html b/docs/posts/static_sites_with_bash/index.html index 86e4a12..67f5d8b 100644 --- a/docs/posts/static_sites_with_bash/index.html +++ b/docs/posts/static_sites_with_bash/index.html @@ -43,26 +43,26 @@

I chose to write in markdown, and convert to html with lowdown.

Directory structure

I host my site on GitHub pages, so docs/ has to be the entry point. Markdown formatted posts go into posts/, get converted into html, and end up in docs/index.html, something like this:

-
posts=$(ls -t ./posts)     # chronological order!
-for f in $posts; do
-    file="./posts/"$f      # `ls` mangled our file paths
-    echo "generating post $file"
-
-    html=$(lowdown "$file")
-    echo -e "html" >> docs/index.html
-done
+
posts=$(ls -t ./posts)     # chronological order!
+for f in $posts; do
+    file="./posts/"$f      # `ls` mangled our file paths
+    echo "generating post $file"
+
+    html=$(lowdown "$file")
+    echo -e "html" >> docs/index.html
+done

Assets

Most static site generators recommend dropping image assets into the site source itself. That does have it’s merits, but I prefer hosting images separately:

-
# strip file extension
-ext="${1##*.}"
-
-# generate a random file name
-id=$( cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 2 | head -n 1 )
-id="$id.$ext"
-
-# copy to my file host
-scp -P 443 "$1" emerald:files/"$id" 
-echo "https://u.peppe.rs/$id"
+
# strip file extension
+ext="${1##*.}"
+
+# generate a random file name
+id=$( cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 2 | head -n 1 )
+id="$id.$ext"
+
+# copy to my file host
+scp -P 443 "$1" emerald:files/"$id" 
+echo "https://u.peppe.rs/$id"

Templating

generate.sh brings the above bits and pieces together (with some extra cruft to avoid javascript). It uses sed to produce nice titles from the file names (removes underscores, title-case), and date(1) to add the date to each post listing!

@@ -77,7 +77,10 @@

I'm Akshay, I go by nerd or nerdypepper on the internet.

I am a compsci undergrad, Rust programmer and an enthusiastic Vimmer. - I write open-source stuff to pass time. I also design fonts: scientifica, curie. + I write open-source stuff to pass time. + I also design fonts: + scientifica, + curie.

Send me a mail at nerdy@peppe.rs or a message at nerdypepper@irc.rizon.net.

-- cgit v1.2.3