diff options
Diffstat (limited to 'docs/posts/static_sites_with_bash/index.html')
-rw-r--r-- | docs/posts/static_sites_with_bash/index.html | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/docs/posts/static_sites_with_bash/index.html b/docs/posts/static_sites_with_bash/index.html index 7c1adda..9eb4846 100644 --- a/docs/posts/static_sites_with_bash/index.html +++ b/docs/posts/static_sites_with_bash/index.html | |||
@@ -10,6 +10,7 @@ | |||
10 | <meta property="og:type" content="website"> | 10 | <meta property="og:type" content="website"> |
11 | <meta property="og:description" content="a static site {for, by, about} me "> | 11 | <meta property="og:description" content="a static site {for, by, about} me "> |
12 | <meta property="og:url" content="https://peppe.rs"> | 12 | <meta property="og:url" content="https://peppe.rs"> |
13 | <link rel="icon" type="image/x-icon" href="/favicon.png"> | ||
13 | <title>Static Sites With Bash - peppe.rs</title> | 14 | <title>Static Sites With Bash - peppe.rs</title> |
14 | <body> | 15 | <body> |
15 | <div class="posts"> | 16 | <div class="posts"> |
@@ -51,17 +52,17 @@ to html with <a href="https://kristaps.bsd.lv/lowdown/">lowdown</a>.</p> | |||
51 | <h3 id="Directory%20structure">Directory structure</h3> | 52 | <h3 id="Directory%20structure">Directory structure</h3> |
52 | 53 | ||
53 | <p>I host my site on GitHub pages, so | 54 | <p>I host my site on GitHub pages, so |
54 | <code>docs/</code> has to be the entry point. Markdown formatted posts | 55 | <code>docs/</code> has to be the entry point. Markdown formatted posts |
55 | go into <code>posts/</code>, get converted into html, and end up in | 56 | go into <code>posts/</code>, get converted into html, and end up in |
56 | <code>docs/index.html</code>, something like this:</p> | 57 | <code>docs/index.html</code>, something like this:</p> |
57 | 58 | ||
58 | <pre><code>posts=$(ls -t ./posts) # chronological order! | 59 | <pre><code>posts=$(ls -t ./posts) # chronological order! |
59 | for f in $posts; do | 60 | for f in $posts; do |
60 | file="./posts/"$f # `ls` mangled our file paths | 61 | file="./posts/"$f # `ls` mangled our file paths |
61 | echo "generating post $file" | 62 | echo "generating post $file" |
62 | 63 | ||
63 | html=$(lowdown "$file") | 64 | html=$(lowdown "$file") |
64 | echo -e "html" >> docs/index.html | 65 | echo -e "html" >> docs/index.html |
65 | done | 66 | done |
66 | </code></pre> | 67 | </code></pre> |
67 | 68 | ||
@@ -72,15 +73,15 @@ assets into the site source itself. That does have it’s | |||
72 | merits, but I prefer hosting images separately:</p> | 73 | merits, but I prefer hosting images separately:</p> |
73 | 74 | ||
74 | <pre><code># strip file extension | 75 | <pre><code># strip file extension |
75 | ext="${1##*.}" | 76 | ext="${1##*.}" |
76 | 77 | ||
77 | # generate a random file name | 78 | # generate a random file name |
78 | id=$( cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 2 | head -n 1 ) | 79 | id=$( cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 2 | head -n 1 ) |
79 | id="$id.$ext" | 80 | id="$id.$ext" |
80 | 81 | ||
81 | # copy to my file host | 82 | # copy to my file host |
82 | scp -P 443 "$1" emerald:files/"$id" | 83 | scp -P 443 "$1" emerald:files/"$id" |
83 | echo "https://u.peppe.rs/$id" | 84 | echo "https://u.peppe.rs/$id" |
84 | </code></pre> | 85 | </code></pre> |
85 | 86 | ||
86 | <h3 id="Templating">Templating</h3> | 87 | <h3 id="Templating">Templating</h3> |